bootstrap导航栏上的搜索框问题 - 我在bootstrap导航栏上遇到了问题。导航栏上的搜索框出现并放在下面(在tab / mobiledeviceview上)。
<nav class="navbar navbar-default">
<div class="container">
<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>
</div>
<div class="row">
<div class="col-sm-10">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="#">HOME</a></li>
<li><a href="#">MEN</a></li>
<li><a href="#">WOMEN</a></li>
<li><a href="#">KIDS</a></li>
<li><a href="#">NEW ARRIVALS</a></li>
<li><a href="#">GOODSALE</a></li>
</ul>
</div>
</div>
<div class="col-sm-2">
<form class="navbar-form navbar-right " role="search">
<div class="form-group form_search">
<input type="text" class=" search_box" placeholder="SEARCH" />
</div>
</form>
</div>
</div>
</div>
</nav>
答案 0 :(得分:2)
该行必须在navbar-header中,如下所示:
<script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
<script src="http://getbootstrap.com/dist/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-default">
<div class="container">
<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>
<div class="row">
<div class="col-sm-10">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="#">HOME</a></li>
<li><a href="#">MEN</a></li>
<li><a href="#">WOMEN</a></li>
<li><a href="#">KIDS</a></li>
<li><a href="#">NEW ARRIVALS</a></li>
<li><a href="#">GOODSALE</a></li>
</ul>
</div>
</div>
<div class="col-sm-2">
<form class="navbar-form navbar-right " role="search">
<div class="form-group form_search">
<input type="text" class=" search_box" placeholder="SEARCH" />
</div>
</form>
</div>
</div>
</div>
</div>
</nav>