导航栏未正确对齐我网站的左右边距。我正在使用Bootstrap' pull-left' &安培; '右拉'功能
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Microbiology Bootstrap!</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="nav">
<div class="container">
<ul class="pull-left">
<li><a href="#">Home</a></li>
<li><a href="#">Contact</a></li>
</ul>
<ul class="pull-right">
<li><a href="#">By Industry</a></li>
<li><a href="#">By Matrix</a></li>
<li><a href="#">By Vial</a></li>
<li><a href="#">All Studies</a></li>
</ul>
</div>
</div>
<div class="jumbotron">
<div class="container">
<h1>Microbiology <br>Bootstrap</br></h1>
<p>Find the validation study you need. <br>Search by industry, matrix or vial.</br></p>
<a href="#">Learn More</a>
</div>
</div>
CSS:
.nav {
background-color: #efefef;
}
.nav a {
color: #5a5a5a;
font-size: 12px;
font-weight: bold;
padding: 14px 10px;
text-transform: uppercase;
}
.nav li {
display: inline;
}
插图:
Home | Contents By Industry | By Matrix | By Vials etc
Microbiology
Bootstrap
非常感谢任何帮助!
答案 0 :(得分:3)
由于您已经加载了bootstrap,因此可以使用bootstrap's navigation来实现相同的功能。在导航栏的navbar-left
上,您需要两个类navbar-right
和ul
。以下是从bootstrap文档中获取的示例代码。
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<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="#">Brand</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-left">
<li class="active"><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Link</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
您必须相应地为您的代码添加类。将navbar
类添加到具有类nav
的div中。
答案 1 :(得分:1)
使用navbar-left,navbar-right代替左拉和右拉