How to toggle the second line of Bootstrap navbar
I am new to Bootstrap and I am building a navbar with a second row. The second line is only called when the search field it contains is required. To invoke it, I have an always-visible-style-link button that works fine in mobile widths, but won't hide it in desktop widths. What will I not get? Below is the HTML and here's a sample Bootply . Thanks in advance ... `
<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 -->
`
+3
source to share
1 answer
Very nice. Just remove the "navbar-collapse" on the collapse surrounding the search.
http://www.bootply.com/5fUw0Xo2vX
<div class="collapse" id="nav2">
<form class="navbar-form" role="search" id="srch-frm">
....
+4
source to share