这是我的jsfiddle:http://jsfiddle.net/edalzell/gujww7d7/1/
HTML就在这里:
<header class= "blog-masthead">
<nav class="navbar" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" 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>
<form class="navbar-form navbar-left" role="search" action="/search" method="get">
<div class="form-group">
<input type="text" class="form-control input-sm" placeholder="Search" id="sitesearch" name="query" value="{{ get:query|sanitize }}">
<button type="submit" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-search"></span></button>
</div>
</form>
</div> <!-- navbar-header -->
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="/blog">Blog</a></li>
<li><a href="/about">About</a></li>
</ul>
</div> <!-- navbar-collapse -->
</div>
</nav>
</header>
当浏览器为&gt;时,我的页面有效。 768像素但小于此值,搜索按钮下降到输入字段下方。我希望它留在旁边。
我看过这里:http://www.mentful.com/2014/06/22/fixed-search-navbar-with-bootstrap-3-0/
请帮助。
答案 0 :(得分:4)
你必须使用&#34;输入组#34;实现这一目标的选择。下面的代码将适合您。
<div class="form-group input-group">
<input type="text" class="form-control input-sm" placeholder="Search" id="sitesearch" name="query" >
<span class="input-group-addon"><button type="submit" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-search"></span></button></span>
</div>
实现这一目标的另一个选择:
<div class="input-group">
<input type="text" class="form-control">
<span class="input-group-btn">
<button class="btn btn-default" type="button">Go</button>
</span>
</div>