Html 我如何将这些 Twitter bootstrap 3 导航栏链接居中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18175040/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I center these Twitter bootstrap 3 navbar links?
提问by Ashley Brown
I'm wondering on how I can center the bootstrap 3's navbar menu items. I know they have included a .nav-justified
class but that will just conflict with navbar-nav
if used together. I belive it is being looked into by the dev team.
我想知道如何将引导程序 3 的导航栏菜单项居中。我知道他们已经包含了一个.nav-justified
类,但navbar-nav
如果一起使用,它就会发生冲突。我相信开发团队正在研究它。
So is there any work around with CSS that I can achieve a navbar that will keep the navbar menu items/links justified even when the container it is in is re-sized.
那么是否有任何使用 CSS 的解决方法,我可以实现导航栏,即使它所在的容器重新调整大小,导航栏菜单项/链接也将保持合理。
Here's a Jsfiddlefor you if you need it.
如果您需要,这里有一个Jsfiddle。
回答by edsioufi
The .nav-justifed
class is to be used with nav-tabs
/ nav-pills
(see bootstrap docs) and not nav-bar
. The two concepts are very different and should not be confused.
的.nav-justifed
类是与使用nav-tabs
/ nav-pills
(见引导文档),而不是nav-bar
。这两个概念非常不同,不应混淆。
However, you can achieve the effect you are looking for by adding the following css
:
但是,您可以通过添加以下内容来实现您正在寻找的效果css
:
.navbar-nav.nav-justified > li{
float:none;
}
nav-justified
now plays nice with navbar-nav
:
nav-justified
现在玩得很好navbar-nav
:
<ul class="nav navbar-nav nav-justified">
See updated jsFiddle.
请参阅更新的 jsFiddle。
回答by X?pplI'-I0llwlg'I -
If using LESS, you can do the following:
如果使用 LESS,您可以执行以下操作:
.navbar-nav {
.nav-justified;
}