Bootstrap navbar-fixed-top类,无效

时间:2017-03-22 09:49:56

标签: html css twitter-bootstrap bootstrap-4

使用Bootstrap构建投资组合网站 - 我正在应用'navbar-fixed-top'类以使导航栏粘在窗口的顶部,例如:

https://getbootstrap.com/examples/navbar-fixed-top/

我正在尝试使用此代码:

<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>

但是,当我将导航栏应用到我自己的网页时,它仍然可以滚动。您可以在此处查看页面:

http://codepen.io/BenWS/pen/gmLEVw

3 个答案:

答案 0 :(得分:35)

因为您使用的是最新版本的bootstrap(bootstrap4 beta6)。

他们从.navbar-fixed-top更改为.fixed-top

您必须阅读此link.

中的文档

答案 1 :(得分:3)

我认为你在引导程序中加载的方式有问题。确保在调用引导程序文件之前调用jquery。如果没有任何效果,您可以随时添加固定位置:

.navbar-fixed-top {
    position:fixed !important;
}

答案 2 :(得分:0)

在边缘安装了bootstrap 4,firefox,镀铬
固定式无点

<nav class="navbar navbar-expand-lg  navbarBGcolor fixed-top">