[英]Scrolling in sticky-top navbar Bootstrap 4
I have a problem because I've made navbar, which is sticky-top and it has got a few dropdowns ( and many buttons in each drop-down). 我有一个问题,因为我已经制作了导航栏,它是粘性顶部,它有一些下拉菜单(每个下拉列表中有许多按钮)。 So if device's height is too small it's cropped and I can get buttons that are lower.
因此,如果设备的高度太小,它会被裁剪,我可以得到更低的按钮。 I need to know how to add scrolling on that navbar.
我需要知道如何在该导航栏上添加滚动。
At this moment it works like that (using bootstrap 4.0) https://v4-alpha.getbootstrap.com/examples/navbar-top-fixed/ 此时它就像那样(使用bootstrap 4.0) https://v4-alpha.getbootstrap.com/examples/navbar-top-fixed/
and in bootstrap 3.3.7 it was easier and it looks like this: https://getbootstrap.com/docs/3.3/examples/navbar-fixed-top/ 并在bootstrap 3.3.7中它更容易,它看起来像这样: https : //getbootstrap.com/docs/3.3/examples/navbar-fixed-top/
Just change the height of windows to 300px and u will see the effect. 只需将窗口高度更改为300px即可看到效果。 I need help with adding scrolling to the sticky-top collapsed navbar.
我需要帮助添加滚动到粘性顶部折叠导航栏。
.fixed-top {
max-height: 100vh;
overflow: auto;
}
...fixes it. ......解决它。 However, it creates another, smaller problem: a double scrollbar.
但是,它会产生另一个较小的问题:双滚动条。 However, this is not a problem on mobiles, because most mobiles only show the scrollbar when it's being used.
但是,这在移动设备上不是问题,因为大多数移动设备仅在使用时显示滚动条。 (It's only a problem on desktop browsers, when you're testing it with browser window very small, in non-mobile mode).
(在非移动模式下,当您使用非常小的浏览器窗口进行测试时,桌面浏览器只会出现问题)。 So, in practice, it's not a problem :).
所以,在实践中,这不是一个问题:)。
I have better results with this: 我有更好的结果:
#nav_collapse {
overflow-y: scroll;
-webkit-overflow-scrolling:touch; // mobile safari
max-height: 90vh;
}
It's almost the same but a little more precise 它几乎相同,但更精确一点
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.