在容器内移动固定引导导航栏

时间:2014-11-21 17:21:07

标签: html5 twitter-bootstrap twitter-bootstrap-3

我正在尝试使用jquery.pagepiling.js和bootstrap创建一个页面。基本上它是一个单页滚动网站,每个页面都适合浏览器窗口。我无法弄清楚如何移动容器内的默认固定导航栏。

http://imgur.com/ssIMPcU

<nav id="menu" class="navbar-fixed-top container">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
    </div>
    <div class="col-sm-4">
        <div class="collapse navbar-collapse" id="navbar-collapse">
            <div class="navbar-inner">
                <ul class="nav">
                    <li data-menuanchor="page1" class="active"><a href="#page1">section1</a>
                    </li>
                    <li data-menuanchor="page2"><a href="#page2">section2</a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</nav>

1 个答案:

答案 0 :(得分:1)

[编辑评论 - 2014-11-210]

将菜单放入容器中,排成一排,非常简单......几乎直接来自引导网站...正如我所说的那样,只需删除navbar-fixed-top以使其自身相对位于其中包含标签。

<!doctype html>
<html>
<head>
    <title>Bootstrap Menu</title>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">

    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
</head>
<body>
    <div class='container'>
        <div class='row'>
            <div class='col-xs-12' style='height:200px;'>I'm the row above</div>
        </div>
        <div class='row'>
            <nav class="navbar navbar-default" 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="#">Brand</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="#">Link <span class="sr-only">(current)</span></a></li>
                    <li><a href="#">Link</a></li>
                    <li class="dropdown">
                      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a>
                      <ul class="dropdown-menu" role="menu">
                        <li><a href="#">Action</a></li>
                        <li><a href="#">Another action</a></li>
                        <li><a href="#">Something else here</a></li>
                        <li class="divider"></li>
                        <li><a href="#">Separated link</a></li>
                        <li class="divider"></li>
                        <li><a href="#">One more separated link</a></li>
                      </ul>
                    </li>
                  </ul>
                  <form class="navbar-form navbar-left" role="search">
                    <div class="form-group">
                      <input type="text" class="form-control" placeholder="Search">
                    </div>
                    <button type="submit" class="btn btn-default">Submit</button>
                  </form>
                  <ul class="nav navbar-nav navbar-right">
                    <li><a href="#">Link</a></li>
                    <li class="dropdown">
                      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a>
                      <ul class="dropdown-menu" role="menu">
                        <li><a href="#">Action</a></li>
                        <li><a href="#">Another action</a></li>
                        <li><a href="#">Something else here</a></li>
                        <li class="divider"></li>
                        <li><a href="#">Separated link</a></li>
                      </ul>
                    </li>
                  </ul>
                </div><!-- /.navbar-collapse -->
              </div><!-- /.container-fluid -->
            </nav>
        </div>
        <div class='row'>
            <div class='col-xs-12' style='height:200px;'><br /><br /><br />I'm the row below</div>
        </div>
    </div>

</body>
</html>