我正在尝试从入门页面试用引导程序。我希望一切都能顺利进行,并且该页面应按照初始页面显示的方式呈现。但是我遇到了一个奇怪的问题(据我所知),不能将主容器放置在页面的中央。实际上,如屏幕截图所示,主容器与导航栏位于相同的位置。 IE和Firefox上的结果相同。而且我还没有自定义bootstrap.min.css。
源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'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>
能否请你帮忙?
最佳答案
您必须向主体添加填充,以便将其推到导航栏下方。将其放在引导文件之后引用的css文件中body { padding-top: 70px; }
关于html - Bootstrap主容器被navbar黯然失色,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51457117/