gpt4 book ai didi

css - 为什么我的页眉被导航栏覆盖? Bootstrap

转载 作者:技术小花猫 更新时间:2023-10-29 10:54:54 25 4
gpt4 key购买 nike

我正在计划使用 boostrap 并想知道为什么当我使用内置类时我的标题仍然被切断。我可以使用 css 来移动它,但我认为在使用 Bootstrap header 类时我不需要添加自己的 css。

这是生成的页面,我使用的是 VS 2013 的 Asp.net MVC 5.1。所以很多内容都在母版页中。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Portfolio - My ASP.NET Application</title>



<link href="/Content/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/modernizr-2.6.2.js"></script>




</head>
<body>
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Application name</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="/home/index">Home</a>
</li>
<li>
<a href="#">Resume</a>
</li>
<li>
<a href="/home/portfolio">Portfolio</a>
</li>
<li>
<a href="#">Contact</a>
</li>
</ul>
</div>
</div>
</div>

<div class="container body-content">



<div class="container">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Portfolio</h1>
</div>
</div>


</div>



<div class="navbar navbar-default navbar-fixed-bottom">
<div class="container">
<p class="navbar-text">&copy; 2014 - My ASP.NET Application</p>
</div>
</div>

</div>

<script src="/Scripts/jquery-2.1.0.min.js"></script>
<script src="/Scripts/bootstrap.min.js"></script>

<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
{"appName":"Firefox","requestId":"c8d12fe59c90426f9175a363b9a06484"}
</script>
<script type="text/javascript" src="http://localhost:58343/af7b5f6142444a738445c2a2e5c5a6d7/browserLink" async="async"></script>
<!-- End Browser Link -->

</body>
</html>

enter image description here

最佳答案

使用固定顶部导航栏时,您必须添加手动填充。

根据 Bootstrap 文档,

Body padding required

The fixed navbar will overlay your other content, unless you add padding to the top of the body tag. 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

关于css - 为什么我的页眉被导航栏覆盖? Bootstrap ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22948843/

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