Bootstrap 导航栏固定顶部 class,不工作

Bootstrap navbar-fixed-top class, not working

使用 Bootstrap 构建投资组合网站 - 我正在应用 'navbar-fixed-top' class 以使导航栏保持在 window 的顶部,例如在这个例子中:

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

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

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

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

它们从 .navbar-fixed-top 变为 .fixed-top

您必须阅读此 link.

中的文档

使用 bootstrap 4 on edge, firefox, chrome
fixed-top without dot

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