div没有固定在Bootstrap的导航栏下方

8
我一直在使用Bootstrap的导航栏CSS。在这个导航栏下面,我有一个div,想把它放在导航栏下面。然而,为什么它总是从顶部开始而不是在导航栏下面?我查看了Twitter Bootstrap的示例,他们能够将一个div定位在固定导航栏下面。这是我的网站链接。您知道为什么会出现这种情况吗?
以下是我现在的HTML代码:
<div class="navbar navbar-fixed-top">
</div>

<section id="main">

</section>
2个回答

15

The fixed navbar will overlay your other content, unless you add padding to the top of the <body>. Try out your own values or use our snippet below. Tip: By default, the navbar is 50px high.

body { padding-top: 70px; }

Make sure to include this after the core Bootstrap CSS.

参考链接: http://getbootstrap.com/components/#navbar-fixed-top

我不知道为什么他们没有在Bootstrap 2.3.2中添加这个注释,但这就是你想要的。 :)


2
昨天我修复了我的导航栏,并将容器设置如下:
.maincontainer{ padding-top: 75px; }

75像素足够了,不会影响Bootstrap在平板电脑和手机上的响应式设计。在任何地方都能完美运行 :)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接