【问题标题】:How to deactivate Bootstrap's scrollspy for mobile viewports?如何为移动视口停用 Bootstrap 的滚动间谍?
【发布时间】:2013-07-03 11:41:59
【问题描述】:

我正在使用 Bootstrap documentation 中使用的 Bootstrap 词缀侧导航。如您所见,当视口小于 768px 并且页面正在切换到移动视图时,scrollspy 没有任何意义。因此,我想在页面切换到移动视图后立即停用 scrollspy。请记住,修复应仅适用于侧边栏导航,而不适用于导航栏。有什么想法吗?

【问题讨论】:

    标签: javascript twitter-bootstrap navigation


    【解决方案1】:

    修复很简单。使用媒体查询并定义位置:静态;用于移动视图的侧边栏导航 div,例如

        @media (max-width: 767px){
    
       .sidenav.affix {         /* change sidenav selector to match your layout */   
    
        position: static;    /* removes the affix behaviour */
        width: auto;         /* customise as required */
        top: 0;               /* customise as required */
        }  
        }
    

    【讨论】:

    • 非常感谢您的回答,花了大约 2 个小时来解决这个问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-04
    • 1970-01-01
    • 2019-02-23
    • 2016-10-12
    • 1970-01-01
    • 2017-04-05
    • 1970-01-01
    相关资源
    最近更新 更多