How to detect which device view you're on using Twitter Bootstrap API?

后端 未结 7 851
小蘑菇
小蘑菇 2020-12-02 06:54

I have just started to play around with Twitter Bootstrap API for a project I have coming up. The main nav contains 3 main elements:

  • site nav
  • social l
相关标签:
7条回答
  • 2020-12-02 07:47

    My answer is using similar mechanism like the one presented by @Raphael_ however, you can do a little bit more with it. Please refer to this answer for details and project's github repository for the most updated version.

    Example of breakpoint detection:

    if ( viewport.is('xs') ) {
      // do stuff in the lowest resolution
    }
    

    Executing code on window resize (without it happening multiple times within a span of milliseconds):

    $(window).bind('resize', function() {
        viewport.changed(function() {
    
          // do some other stuff!
    
        })
    });
    
    0 讨论(0)
提交回复
热议问题