Div under fixed top bar

我们两清 提交于 2020-01-07 05:38:06

问题


I want a fixed top bar, with content below. However, if I don't set the margin top the content of this div will be placed under the fixed top bar.

<nav class="navbar navbar-default navbar-fixed-top">
    <div id="navbar" class="navbar-collapse collapse"></div>
    </div>
</nav>
<div class="container">
     <h1>Navbar example</h1>
     <h1>Navbar example</h1>
     <h1>Navbar example</h1>
     <h1>Navbar example</h1>
     <h1>Navbar example</h1>
</div>

Set a margin top is the correct way, or there is some way in boostrapt to make this?

http://jsfiddle.net/5f5g3mu0/


回答1:


See the Docs.

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

body {
    padding-top:70px;
}


来源:https://stackoverflow.com/questions/33269611/div-under-fixed-top-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!