twitter-bootstrap 如何使 twitter bootstrap 导航栏固定宽度?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13780471/
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 to make twitter bootstrap navbar fixed width?
提问by Harry M
How can I make twitter bootstrap navbar fixed width, while keeping it centered?
如何使 twitter bootstrap 导航栏固定宽度,同时保持居中?
I've tried adding a width parameter in .navbar, but then the navbar is misaligned.
我尝试在 .navbar 中添加宽度参数,但随后导航栏未对齐。
.navbar {
overflow: visible;
margin-bottom: 20px;
color: #956362;
*position: relative;
*z-index: 2;
width: 650px;
}
I also tried
我也试过
<div class="span6 offset3">
but this also makes it misaligned.
但这也使它错位。
回答by Philipp Hofmann
Surround it with a div. Give that div a fixed width.
用 div 包围它。给那个 div 一个固定的宽度。
Something like:
就像是:
<div class="navbar-outer">
<div class="navbar">
<!--here goes the rest of the code-->
</div>
</div>
CSS:
CSS:
.navbar-outer {
width:500px;
}

