我正在使用 Bootstrap documentation 中使用的 Bootstrap 词缀侧面导航。正如您所看到的,当视口(viewport)小于 768px 并且页面切换到移动 View 时,scrollspy 没有任何意义。因此,我想在页面切换到移动 View 后立即停用滚动 spy 。请记住,修复应该仅适用于侧边栏导航,而不适用于导航栏。有什么想法吗?
最佳答案
修复很简单。使用媒体查询并定义position:static;用于移动 View 的侧边栏导航 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 */
}
}
关于javascript - 如何停用 Bootstrap 的移动视口(viewport)滚动监视?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17447017/