[英]Bootstrap <div class=“navbar navbar-fixed-top”>
I am trying to built a site with Bootstrap. 我正在尝试使用Bootstrap构建一个站点。 So far everything is going pretty much as planned.
到目前为止,一切都按计划进行。 I would like a fixed navbar and I am using the built in function:
我想要一个固定的导航栏,我正在使用内置功能:
<div class="navbar navbar-fixed-top">
This is great and just what I need BUT I would like the navigation and title to start at the same place as the container instead of all the way to the left/right (still having the navbar going 100% in width. I have tried to put a container inside the navbar which was not the correct solution :-) 这很棒,正是我需要的但是我希望导航和标题从与容器相同的位置开始而不是一直向左/向右(仍然使导航栏的宽度达到100%。我试过在导航栏中放置一个容器,这不是正确的解决方案:-)
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="./index.html">Bootstrap</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active">
<a href="./index.html">Home</a>
</li>
<li>
<a href="./getting-started.html">Get started</a>
</li>
...
<li>
<a href="./customize.html">Customize</a>
</li>
</ul>
</div>
</div>
</div>
</div>
or throw 或扔
.navbar {
max-width: 1170px; /* width of .container */
margin: 0 auto;
}
into the css 进入CSS
You should have a container class nested inside your navbar 您应该在导航栏中嵌套一个容器类
<div class="navbar navbar-fixed-top">
<div class="container">your menu and logo go here</div>
</div>
That will give you the same width as the body container if you do not have a fluid layout and will give auto margins to the container so it is centered in the middle of the screen. 如果您没有流体布局,那么将为您提供与主体容器相同的宽度,并为容器提供自动边距,使其位于屏幕中间的中心位置。 It will also keep the navbar itself at 100%
它还会使导航栏本身保持在100%
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.