我希望将品牌集中在一个引导导航栏中,并在左侧和右侧都有其他菜单项。
我已按照here获得了正常工作的代码,但我遇到的问题是表单字段,即搜索框,因品牌宽度设置为100%。
http://www.bootply.com/9toJrFqb7M
为方便起见,重新发布了代码:
HTML:
fb://event?id={event-id}
CSS:
<nav class="navbar navbar-inverse navbar-fixed-top top-nav">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="collapse-content" 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>
</div>
<a class="navbar-brand" href="/">Brand</a>
<!-- 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-left">
<li><a href="#">Menu</a></li>
<li><a href="#">Menu</a></li>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
</form>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div>
</nav>
答案 0 :(得分:0)
使用左侧位置居中navbar-brand
,而不是将宽度设置为100%
.navbar-brand {
position: absolute;
left: 50%;
text-align: center;
margin: auto;
font-size: 36px;
}