css - 在页面之间切换导航栏 Bootstrap 3.2

标签 css html twitter-bootstrap

如何让我的导航在页面的不同部分之间切换。在 Bootstrap 3.2 的帮助下?
这是 Bootply:http://www.bootply.com/uYEGumbIK0

<nav class="navbar navbar-default navbar-fixed-bottom" 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 collapsed" 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 class="navbar-brand" href="#">Alive Chance</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">
        <li class="active"><a href="#">Home</a></li>
        <li><a href="#">Link</a></li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

最佳答案

您可以将#Id 添加到不同的部分,例如(div's),然后在您的菜单 (href) 中添加该 ID。就像下面的例子。

这是您的代码的工作示例:

http://www.bootply.com/9A48rvqGh8 CSS:

/* CSS used here will be applied after bootstrap.css */
#part-1{
  background: green;
}
#part-2{
  background: orange;
}

与:

<nav class="navbar navbar-default navbar-fixed-bottom" 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 collapsed" 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 class="navbar-brand" href="#">Alive Chance</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">
        <li class="active"><a href="#part-1">Home</a></li>
        <li><a href="#part-2">Link</a></li>
        <li><a href="#part-3">Link 2</a></li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

<div class="container">
  <div class="row">
    <div class="col-md-12" id="part-1">
        <h1>What is lorem ipsum</h1>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
    </div>

 </div>
  <div class="row">
    <div class="col-md-12" id="part-2">
        <h1>What is lorem ipsum</h1>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
    </div>

 </div>
  <div class="row">
    <div class="col-md-12" id="part-3">
        <h1>What is lorem ipsum</h1>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>  
    </div>

  </div>
</div>

有了它,您可以切换到页面上的不同部分。

关于css - 在页面之间切换导航栏 Bootstrap 3.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27074527/

相关文章:

jquery - 当您使用 jQuery 单击图像/按钮时,从页面顶部向下滑动隐藏元素

html - 将 subdiv 高度设置为未指定高度的父 div 的 33%

html - 在 Controller 中添加 css

css - 更改字段中的日期选择器 Bootstrap 边距

html - 在每个屏幕上创建具有完美高度的部分

jquery - 图表 : How to place the legend on the right of the chart

html - 如何解决 scss 中相同组件的不同颜色?

javascript - jquery- 改变 css 但不能重置为 original-fadein() 导致程序也停止工作

html - 奇怪的 IE6/IE 布局错误

html - flex 容器的高度意外改变