我正在尝试使用bootstrap创建一个全宽度导航栏,但导航中有一种限制
像这样:
我真正想做的就是这样的事情
@import url(https://fonts.googleapis.com/css?family=Raleway:400,700,300,100);
body {
font-family: "Raleway", Sans-Serif;
font-weight: 400;
}
p {
text-align: justify;
font-size: 16px;
}
.navbar {
font-weight: 700;
letter-spacing: 2px;
text-transform: uppercase;
}
.navbar-default .navbar-nav .active a,
.navbar-default .navbar-nav .active a:focus,
.navbar-default .navbar-nav .active a:hover,
.navbar-default .navbar-nav li a:hover {
color: #e1b315;
}
.navbar .navbar-nav {
display: inline-block;
float: none;
}
.navbar-default .navbar-nav li {
margin: 0 15px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>
<div class="row">
<div class="col-md-12 text-center">
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Features</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</div>
</nav>
</div>
</div>
答案 0 :(得分:2)
<强>解决方案强>
.row
或.container
将内容换行为全宽。body
&#39; margin
和padding
。<强>段强>
@import url(https://fonts.googleapis.com/css?family=Raleway:400,700,300,100);
body {
font-family: "Raleway", Sans-Serif;
font-weight: 400;
margin: 0; padding: 0;
}
p {
text-align: justify;
font-size: 16px;
}
.navbar {
font-weight: 700;
letter-spacing: 2px;
text-transform: uppercase;
}
.navbar-default .navbar-nav .active a,
.navbar-default .navbar-nav .active a:focus,
.navbar-default .navbar-nav .active a:hover,
.navbar-default .navbar-nav li a:hover{
color:#e1b315;
}
.navbar .navbar-nav {
display: inline-block;
float: none;
}
.navbar-default .navbar-nav li {
margin: 0 15px;
}
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="text-center">
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Features</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</div>
</nav>
</div>
&#13;
答案 1 :(得分:0)
这不是唯一的方法,但会完成这项工作。
body {
font-family: "Raleway", Sans-Serif;
font-weight: 400;
margin: 0;
}
只需将margin: 0;
添加到您的正文CSS
我已将导航栏设为绿色,因此更容易看到。
@import url(https://fonts.googleapis.com/css?family=Raleway:400,700,300,100);
body {
font-family: "Raleway", Sans-Serif;
font-weight: 400;
margin: 0;
}
p {
text-align: justify;
font-size: 16px;
}
.navbar {
font-weight: 700;
letter-spacing: 2px;
text-transform: uppercase;
background-color: green;
}
.navbar-default .navbar-nav .active a,
.navbar-default .navbar-nav .active a:focus,
.navbar-default .navbar-nav .active a:hover,
.navbar-default .navbar-nav li a:hover {
color: #e1b315;
}
.navbar .navbar-nav {
display: inline-block;
float: none;
}
.navbar-default .navbar-nav li {
margin: 0 15px;
}
&#13;
<div class="row">
<div class="col-md-12 text-center">
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a>
</li>
<li><a href="#">Features</a>
</li>
<li><a href="#">Contact Us</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
&#13;