我试图得到这个:
但是不要得到它(笑)并改为:
不知道在哪里调整东西。
@import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: black;
box-shadow: inset 0px -6px 0px #000;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: black;
box-shadow: inset 0px -6px 0px #000;
}
#menu {
height: 140px;
}

<header>
<nav class="navbar navbar-default" id="menu">
<div class="container-fluid">
<div class="row">
<div class="col-md-3 col-sm-3">
<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="index.html">
<img alt="Brand" src="img/logo.png" height="100px;">
</a>
</div>
</div>
<div class="col-md-9 col-sm-9">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav ">
<li class="active"><a href="#">Accueil <span class="sr-only">(current)</span></a></li>
<li><a href="#">Page 1</a></li>
<li><a href="#">Page 2</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</div>
</div>
</div>
</nav>
</header>
&#13;
你知道吗?当我试图用高度修复它时,它增加了导航栏的高度......
答案 0 :(得分:3)
尝试添加此代码:
.navbar-default .navbar-nav > li > a {
line-height: 140px; /* = height of #menu */
padding-bottom: 0;
padding-top: 0;
}
检查结果:
@import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: black;
box-shadow: inset 0px -6px 0px #000;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: black;
box-shadow: inset 0px -6px 0px #000;
}
#menu {
height: 140px;
}
.navbar-default .navbar-nav > li > a {
line-height: 140px; /* = height of #menu */
padding-bottom: 0;
padding-top: 0;
}
<header>
<nav class="navbar navbar-default" id="menu">
<div class="container-fluid">
<div class="row">
<div class="col-md-3 col-sm-3">
<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="index.html">
<img alt="Brand" src="img/logo.png" height="100px;">
</a>
</div>
</div>
<div class="col-md-9 col-sm-9">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav ">
<li class="active"><a href="#">Accueil <span class="sr-only">(current)</span></a></li>
<li><a href="#">Page 1</a></li>
<li><a href="#">Page 2</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</div>
</div>
</div>
</nav>
</header>