twitter-bootstrap Bootstrap 导航栏固定顶级类,不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42947983/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap navbar-fixed-top class, not working
提问by BenWS
Building out portfolio site using Bootstrap - I'm applying the 'navbar-fixed-top' class in order to get the navbar to stick to the top of the window, such as in this example:
使用 Bootstrap 构建投资组合站点 - 我正在应用 'navbar-fixed-top' 类以使导航栏粘在窗口的顶部,例如在本例中:
https://getbootstrap.com/examples/navbar-fixed-top/
https://getbootstrap.com/examples/navbar-fixed-top/
I'm trying to do so using this code:
我正在尝试使用以下代码:
<nav class="navbar navbar-fixed-top">
<div class="container">
<div id="navbar" class="navbar-collapse">
<ul class="nav navbar-nav">
<li>About</li>
<li>Projects</li>
<li>Contact Me</li>
</ul>
</div>
</div>
</nav>
However, the navbar is still scrollable when I apply it to my own webpage. You can view the page here:
但是,当我将导航栏应用到我自己的网页时,它仍然可以滚动。您可以在此处查看页面:
回答by lahphim
回答by Arjan Knol
I think there is something wrong with the way your are loading in your bootstrap. Make sure you call jquery before you call the bootstrap files. If nothing works you could always add the fixed positioning yourself:
我认为您在引导程序中加载的方式有问题。确保在调用引导文件之前调用 jquery。如果没有任何效果,您可以随时自己添加固定定位:
.navbar-fixed-top {
position:fixed !important;
}
回答by MaGiaTech
working with bootstrap 4 on edge, firefox, chrome
fixed-top without dot
在边缘、firefox、chrome
固定顶上使用 bootstrap 4,没有点
<nav class="navbar navbar-expand-lg navbarBGcolor fixed-top">

