如何切换第二行Bootstrap导航栏

时间:2014-11-04 01:32:42

标签: html css twitter-bootstrap

我是Bootstrap的新手,我正在构建一个第二行的导航栏。第二行仅在需要包含其搜索框时调用。为了调用它,我有一个始终可见的按钮样式链接,可以在移动设备宽度中完美地工作,但不会将其隐藏在桌面宽度中。我得不到什么?以下是HTML和here's a Bootply sample。提前谢谢......`   

<div class="navbar-header">
  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#nav1">
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
  </button>
  <div class="btn-group">
        <a class="btn btn-inverse navbar-btn" href="#" title="Search" data-toggle="collapse" data-target="#nav2">
            <span class="glyphicon glyphicon-search white"></span>
        </a>    
        <a class="navbar-brand" rel="home" href="#" title="Title">Brand</a>         
    </div>
</div>


<div class="collapse navbar-collapse" id="nav1">
  <ul class="nav navbar-nav">
    <li class="active"><a href="#">Home</a></li>
    <li><a href="#about">About</a></li>
    <li><a href="#contact">Contact</a></li>
  </ul>
</div><!--/.nav-collapse -->


<div class="collapse navbar-collapse" id="nav2">
  <form class="navbar-form" role="search" id="srch-frm">
            <div class="input-group">
                <input class="form-control typeahead" placeholder="Search" name="pn" id="srch-term" type="text">
                <div class="input-group-btn">
                    <button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
                </div>
            </div>
        </form> 
</div><!--/.nav-collapse -->

`

1 个答案:

答案 0 :(得分:4)

非常好。只需在搜索周围的折叠中删除“navbar-collapse”即可。

http://www.bootply.com/5fUw0Xo2vX

<div class="collapse" id="nav2">
  <form class="navbar-form" role="search" id="srch-frm">
  ....