我在这里有一个导航栏,看起来就像我想要它在桌面上一样。
http://www.bootply.com/it7sRdkVIA
但是,在手机上,我不希望搜索框在另一条线上。我想要它,以便它显示在同一行。我希望搜索框显示在Calcs品牌名称的右侧。
如何让navbar-Brand和navbar-form同时在移动视图中位于同一行?
答案 0 :(得分:1)
您需要使用一些CSS来定位它。
*我还调整了您的下拉列表以使用课程navbar-right
请参阅Docs。
参见工作示例。
.navbar-custom .formSearch {
width: 300px;
float: left;
padding-top: 8px;
left: -65px;
}
@media (max-width: 767px) {
.navbar-custom .formSearch {
padding-left: 5px;
width: 50%;
left: -85px;
}
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<nav class="navbar navbar-inverse navbar-custom" id="navbar">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button> <a href="#" class="navbar-brand goto-home-page">Calcs</a>
<form class="formSearch" role="search">
<input type="text" class="form-control" placeholder="Search for a calculator" id="txtCalcSearcher">
</form>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Username <span class="caret"></span></a>
<ul class="dropdown-menu">
<li> <a href="#" id="import">Import</a>
</li>
<li> <a href="#" id="btnLogout">Sign out</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
&#13;