gpt4 book ai didi

jquery - 导航下方/后方的 Bootstrap 内容

转载 作者:行者123 更新时间:2023-12-01 07:53:33 26 4
gpt4 key购买 nike

为什么相同的代码在 bootstrap 示例中具有很好的上边距,但如果我将其放在 jsfiddle 中,内容就会位于导航下方

http://jsfiddle.net/a60x81gw/

http://getbootstrap.com/examples/starter-template/

我正在使用这些库

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

代码

    <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Project name</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>

<div class="container">

<div class="starter-template">
<h1>Bootstrap starter template</h1>
<p class="lead">Use this document as a way to quickly start any new project.<br> All you get is this text and a mostly barebones HTML document.</p>
</div>

</div>

最佳答案

该模板在 body 上包含一个 padding,以避免与固定导航栏重叠。

body {
padding-top: 50px;
}

如文档中所述:

Body padding required 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.

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

关于jquery - 导航下方/后方的 Bootstrap 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26677127/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com