gpt4 book ai didi

html - Bootstrap 主容器被导航栏遮挡

转载 作者:太空宇宙 更新时间:2023-11-04 01:09:36 25 4
gpt4 key购买 nike

我正在尝试从起始页 Bootstrap 。我希望一切顺利,页面应该像起始页显示的那样呈现。但是我遇到了一个奇怪的问题(据我所知),主容器不能放在页面的中心。事实上,主容器与导航栏位于同一位置,如屏幕截图所示。 IE 和 Firefox 上的结果相同。而且我还没有自定义 bootstrap.min.css。

the position of main container in inspection mode

html源码如下:

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../../../favicon.ico">
<title>Starter Template for Bootstrap</title>
<!-- Bootstrap core CSS-->
<link href="/stylesheets/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template-->
</head>

<body>
<nav class="navbar navbar-expand-sm navbar-dark fixed-top" style="background-color: #124191;">
<a class="navbar-brand" href="#">
<Google></Google>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item"><a class="nav-link" href="#">Google </a></li>
<li class="nav-item"><a class="nav-link" href="#">Google</a></li>
<li class="nav-item"><a class="nav-link" href="#">Google</a></li>
<li class="nav-item"><a class="nav-link" href="#">Google</a></li>
<li class="nav-item"><a class="nav-link" href="#">Google</a></li>
<li class="nav-item"><a class="nav-link" href="#">Google</a></li>
<li class="nav-item"><a class="nav-link" href="#">Google</a></li>
<li class="nav-item dropdown"><a class="nav-link dropdown-toggle" id="dropdown01" href="https://example.com" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
<div class="dropdown-menu" aria-labelledby="dropdown01"><a class="dropdown-item" href="#">Action</a><a class="dropdown-item" href="#">Another action</a><a class="dropdown-item" href="#">Something else here</a></div>
</li>
</ul>
</div>
</nav>
<main class="container" role="main">
<div class="card" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card&apos;s content.</p><a class="card-link" href="#">Card link</a><a class="card-link" href="#">Another link</a></div>
</div>
</main>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="/javascripts/bootstrap.min.js"></script>
</body>

</html>

你能帮忙吗?

最佳答案

您必须向主体添加填充,以便将其推到导航下方。把它放在你的 Bootstrap 文件之后引用的 css 文件中

body { padding-top: 70px; }

关于html - Bootstrap 主容器被导航栏遮挡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51457117/

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