使用Bootstrap滚动到第一部分后修复导航栏

时间:2014-04-06 09:52:21

标签: html css twitter-bootstrap navigation sticky

我想滚动到放置第一个部分ID的位置后我的导航栏变得粘滞(想想单页网站,我希望当人滚动到第一个“部分”时导航变得固定)

到目前为止,这是我的HTML:

<div class="container">
  <nav class="navbar navbar-default navGUI" role="navigation">
     <div class="container-fluid">
      <!-- Brand and toggle get grouped for better mobile display -->
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>

        <a href="index.html"><img src="assets/img/logo.svg" width="183px" height="65px" alt="logo" class="topLogo"></a>
      </div>

      <!-- Collect the nav links, forms, and other content for toggling -->
      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

        <ul class="nav navbar-nav navbar-right">
          <li><a class="smoothScroll" href="#section-1">Quienes Somos</a></li>
          <li><a class="smoothScroll" href="#">Productos</a></li>
          <li><a class="smoothScroll" href="#">Proyectos</a></li>
          <li><a class="smoothScroll" href="#">Contáctenos</a></li>
        </ul>
      </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
  </nav>
</div>

1 个答案:

答案 0 :(得分:0)

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

有关详细信息,请参阅bootstrap文档