本文介绍了将 Bootstrap 导航对齐到中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在使用 bootstrap 3 导航时遇到问题,我在左侧、中间和右侧都有一些内容.似乎没有使导航居中的选项.
http://jsfiddle.net/29tQt/embedded/result/>
我想让标题为center"的链接位于页面的中心,我该如何实现?
<div class="container-fluid"><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"><span class="sr-only">切换导航</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>按钮><a class="navbar-brand" href="#">Brand</a>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"><ul class="nav navbar-nav"><li class="active"><a href="#">Center</a><li><a href="#">Center</a><li><a href="#">Center</a><ul class="nav navbar-nav navbar-right"><li><a href="#">右</a><li><a href="#">右</a>
</nav>
解决方案
感谢大家的帮助,我添加了这段代码,似乎解决了问题:
.navbar .navbar-nav {显示:内联块;浮动:无;}.navbar .navbar-collapse {文本对齐:居中;}
来源
响应式引导导航栏中的中心内容
I'm having a problem with bootstrap 3 navigation, i have some content on the left, center and right. it seems there is no option for centering the navigation.
http://jsfiddle.net/29tQt/embedded/result/
I'm trying to get the links titled "center" to be in the center of the page, how can i achieve that ?
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" 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> <a class="navbar-brand" href="#">Brand</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Center</a>
</li>
<li><a href="#">Center</a>
</li>
<li><a href="#">Center</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Right</a>
</li>
<li><a href="#">Right</a>
</li>
</ul>
</div>
</div>
</nav>
解决方案
Thank you all for your help, I added this code and it seems it fixed the issue:
.navbar .navbar-nav {
display: inline-block;
float: none;
}
.navbar .navbar-collapse {
text-align: center;
}
Source
Center content in responsive bootstrap navbar
这篇关于将 Bootstrap 导航对齐到中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!