Toni Michel Caubet
Toni Michel Caubet

Reputation: 20163

javascript/jquery plugin to add support to media queries

found out about this jquery plugin that adds support to media queries

So you can use:

<link rel="stylesheet" type="text/css" href="wider.css" media="only screen and (min-width: 1200px)" /> 
<link rel="stylesheet" type="text/css" href="handheld-iphone.css" media="only screen and (max-width: 480px), handheld" />

and so on, but it does not support this kind of media queries (in stylesheet)

@media screen and (max-width: 1024px) {
    body{background:red}
}
@media screen and (max-width: 740px) {

    body{background:yellow}
}

Is there any that does?

Upvotes: 0

Views: 1938

Answers (3)

Mesut Tasci
Mesut Tasci

Reputation: 3120

You should look at enquire.js.

Upvotes: 1

Joonas
Joonas

Reputation: 7303

You could do something like this as well

http://jsfiddle.net/47DSD/

 $(document).ready(function() {

     function wResize() {

             var winW = $(window).width();
             var Body = $('body');

         if ( winW < '1024') {
             Body.css({ 'background-color':'red' }); 
         }
         if ( winW < '740' ) {
             Body.css({ 'background-color':'yellow' }); 
         }         

     }

     wResize();

    $(window).resize(function() {
        wResize();
    });

 });

Edit:

You didnt seem to warm up to this, so how about a little more extensive example?

http://jsfiddle.net/47DSD/1/

Upvotes: 1

user926352
user926352

Reputation:

Wouter van der Graaf made a javascript plugin for media query support in browsers that don't natively support it:

http://code.google.com/p/css3-mediaqueries-js/

Upvotes: 0

Related Questions