Modernizr – bbird.me http://bbird.me WordPress quick tips Wed, 08 Aug 2018 16:39:07 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.8 Creating media queries using Modernizr and jQuery http://bbird.me/creating-media-queries-using-modernizr-jquery/ http://bbird.me/creating-media-queries-using-modernizr-jquery/#respond Thu, 10 Mar 2016 16:40:38 +0000 http://bbird.me/?p=401 Modernizr can do lots of things – one of them is the ability to mix media query function with jQuery

Post Creating media queries using Modernizr and jQuery je prvi puta viđen na bbird.me.

]]>
Modernizr can do lots of things – one of them is the ability to mix media query function with jQuery functions. Although there are other ways to achieve this, even (or especially) within jQuery itself, if using Modernizr for some other things on your website, you can try something like the following:

$(document).ready(function() {
  if (Modernizr.mq("screen and (max-width:480px)")) {
    $("li").addClass("myClass");
  }
});

li {
  color: #FFF;
}

.myClass {
  color: #000;
}

and finally some HTML:

<ul>
  <li>CHANGE COLOR</li>
</ul>

If this piece of HTML is loaded on resolution below 480px, .myClass will be added.

Post Creating media queries using Modernizr and jQuery je prvi puta viđen na bbird.me.

]]>
http://bbird.me/creating-media-queries-using-modernizr-jquery/feed/ 0