Twitter Bootstrap - how to detect when media queries starts

后端 未结 16 757
抹茶落季
抹茶落季 2020-12-14 02:19

which is the fastest and easy way to fire when bootstrap-responsive.css media queries go in action?

go in action = when you resize window to mobile width and site is

16条回答
  •  离开以前
    2020-12-14 02:43

    Using jquery you can find the size of current window and then accordingly do your stuff.

    $(window).resize(function() {
      if ($(this).width() >= 1280) {
        //do something
      }
      else if ($(this).width() < 1280 && $(this).width()>= 980) {
        //do something
      }
      ...
    });
    

    CSS:: Twitter-Bootsrap-layouts

    /* Large desktop */
    @media (min-width: 1200px) { ... }
    
    /* Portrait tablet to landscape and desktop */
    @media (min-width: 768px) and (max-width: 979px) { ... }
    
    /* Landscape phone to portrait tablet */
    @media (max-width: 767px) { ... }
    
    /* Landscape phones and down */
    @media (max-width: 480px) { ... }
    

提交回复
热议问题