有没有办法让品牌名称集中在导航栏中
我目前的代码就像
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<ul class="nav pull-left">
<li> <button class="btn btn-primary"> < Back </button> </li>
</ul>
<p class="brand"> Report </p>
<ul class="nav pull-right">
<li> <button class="btn btn-primary pull-right"> New Report </button> </li>
</ul>
</div>
</div>
</div>
答案 0 :(得分:21)
上述答案不适用于版本2(响应式设计):
而是将您的品牌包装在div中:
<div class="brand">
<a href="/">YOUR BRAND</a>
</div>
并在替换样式表中重新定义.brand样式:
.brand
{
position: absolute;
width: 100%;
left: 0;
text-align: center;
margin: auto;
}
答案 1 :(得分:6)
如果想要集中注意力,你可能需要尝试各自:
设置自动边距:
.brand { margin-left: auto; margin-right: auto; }
或使用已知宽度(200px示例)的绝对定位元素:
.brand { left: 50%; margin-left: -100px; }
答案 2 :(得分:1)
终于让它运转了(由我完美检查)
HTML是:
<div class="navbar navbar-fixed-top center" >
<div class="navbar-inner">
<ul class="nav">
<li><a href="#">Doctors List</a></li>
</ul>
</div>
CSS是:
.center.navbar .nav,
.center.navbar .nav > li {
float:none;
display:inline-block;
*display:inline; /* ie7 fix */
*zoom:1; /* hasLayout ie7 trigger */
vertical-align: top;
}
.center .navbar-inner {
text-align:center;
}
答案 3 :(得分:1)
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="#"> <img src="img/logo.png"></a> <!-- move here your logo -->
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="#!"><i class="fa fa-pencil"></i> Crear Post</a></li>
<li class="dropdown">
<a href="#!" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></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 role="separator" class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#!">Separated link</a></li>
<li><a href="#!">One more separated link</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#!">Iniciar Sesión</a></li>
<li><a href="#!">Registrarse</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
.navbar-brand {
left: calc(50% - 65.5px); //65.5px It is half the width of my logo.jpg
position: absolute;
}