简体   繁体   English

div不会将自己定位在bootstrap固定导航栏下面

[英]div doesn't position itself below bootstrap fixed navbar

I have been using bootstrap's navbar css. 我一直在使用bootstrap的navbar css。 Below this navbar I have a which I want to put below the navbar. 在这个导航栏下面,我有一个我想要放在导航栏下方。 However, why does it always start at the top and not below the navbar? 但是,为什么它总是从顶部开始而不是在导航栏下方? I've looked at twitter bootstrap's example and they were able to have a positioned below the fixed navbar. 我查看了twitter bootstrap的示例,他们能够在固定导航栏下方定位。 Here's the link to my website . 这是我网站的链接。 Any idea why this is? 知道为什么会这样吗?

Here's the html that I have now: 这是我现在的HTML:

<div class="navbar navbar-fixed-top">
</div>

<section id="main">

</section>

The fixed navbar will overlay your other content, unless you add padding to the top of the <body> . 除非您在<body>的顶部添加padding ,否则fixed navbar将覆盖您的其他内容。 Try out your own values or use our snippet below. 尝试自己的价值观或使用下面的代码段。 Tip: By default, the navbar is 50px high. 提示:默认情况下,导航栏高50像素。

 body { padding-top: 70px; } 

Make sure to include this after the core Bootstrap CSS. 确保在核心Bootstrap CSS之后包含它。

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

I dont know why they dont put this note in bootstrap 2.3.2 but this is what you want. 我不知道为什么他们不把这个音符放在bootstrap 2.3.2中,但这就是你想要的。 :) :)

Yesterday I fix my navbar and set the container as following 昨天我修复了我的导航栏并将容器设置如下

.maincontainer{ padding-top: 75px; }

75 pixel is enough and doesn't affect Bootstrap on Responsive design in Tablet and Mobile. 75像素就足够了,不会影响Tablet和Mobile中响应式设计的Bootstrap。 Work perfect everywhere :) 到处工作完美:)

Just use the <nav> tag instead of <div class="nav"> . 只需使用<nav>标签而不是<div class="nav"> It'll take care of it. 它会照顾它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM