标题导航栏也没响应。没工作
.head2 {
background-color: lightgreen;
margin-left: -10px;
}
.navbar {
background-color: black;
}
.navbar-brand {
padding-left: 70px;
text-align: center;
}
.nav .navbar-nav li a {
color: white;
}
.color-me {
color: white;
}
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header head2 col-sm-2 ">
<a class="navbar-brand " href="#">androbo</a>
</div>
<div class="col-sm-6">
</div>
<div class="col-sm-4">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Service</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</div>
</nav>
答案 0 :(得分:0)
要快速修复,请将其添加到CSS
.container-fluid { padding: 0; }
答案 1 :(得分:0)
默认情况下,您的父元素.container-fluid
左右填充15px ...您需要删除.container-fluid
中的填充,我建议您创建一个CSS规则,如下所示并将其应用于您需要/想要删除填充的任何元素:
.no-padding {
padding: 0 !important;
}
.head2{
background-color: lightgreen;
margin-left:-10px;
}
.navbar{
background-color:black;
}
.navbar-brand {
padding-left:70px;
text-align: center;}
.nav .navbar-nav li a{
color:white;
}
.color-me{
color:white;
}
.no-padding {
padding: 0 !important;
}
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-default">
<div class="container-fluid no-padding">
<div class="navbar-header head2 col-xs-3 " >
<a class="navbar-brand " href="#">androbo</a>
</div>
<div class="col-xs-5">
</div>
<div class="col-xs-4">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Service</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</div>
</nav>
答案 2 :(得分:0)
您可以使用Bootstrap框架尝试此操作。 请注意:Bootsrtap navbar。这将解决您的问题。