我是 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 -->

`

最佳答案

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

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

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

关于html - 如何切换 Bootstrap 导航栏的第二行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26726327/

10-12 04:45