在下图中,如果您查看箭头所指向的位置,您可以看到导航栏的一小段不会在打开下拉列表时“突出显示”。我以前从未见过这个,也不知道是什么导致它,如果有人能解释为什么会发生这种情况会很棒。这是JSFiddle。
Navbar代码
<nav class="navbar navbar-default">
<div class="container-fluid">
<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>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
@if(!Auth::check())
<li><a href="login"><img class="navbar-avatar" src="{{ asset('src/img/login_steam.png') }}"></a></li>
@else
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><span>{{ Auth::user()->username }}</span><img class="navbar-avatar" src="{{ Auth::user()->avatar }}"></a>
<ul class="dropdown-menu">
<li><a href="#">Dashboard</a></li>
<li><a href="#">Settings</a></li>
<li><a href="#">Logout</a></li>
</ul>
</li>
@endif
</ul>
</div>
</div>
</nav>
CSS
.navbar {
margin-bottom: 0;
height: 70px;
}
.navbar-default {
background-color: #383838;
border-color: #383838;
}
/* title */
.navbar-default .navbar-brand {
color: #777;
}
.navbar-default .navbar-brand:hover,
.navbar-default .navbar-brand:focus {
color: #5E5E5E;
}
/* link */
.navbar-default .navbar-nav > li > a {
color: #8D8D8D;
font-family: Open Sans;
font-size: 14px;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: #8D8D8D;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: #6C6C6C;
}
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:hover,
.navbar-default .navbar-nav > .open > a:focus {
color: #6C6C6C;
background-color: #2E2E2E;
}
.navbar-avatar {
width: 45px;
height: 45px;
position: relative;
float: right;
top: -4px;
margin-left: 8px;
margin-right: 8px;
}
.navbar-user {
padding: 0;
margin: 0;
display: inline-block;
padding-top:7px;
}
.navbar-steam {
position: relative;
float: right;
top: 8.6px;
margin-right: 8px;
}
.navbar-nav > li > a {
padding-top: 15px;
padding-bottom: 25px;
}
答案 0 :(得分:1)
这是一个更新的小提琴:
https://jsfiddle.net/tobyl/Laaej9ya/
我做的唯一改变是:
.navbar {
margin-bottom: 0;
height: 68px;
}
.navbar
的高度和控制下拉位置的元素的高度略有不同。
答案 1 :(得分:0)
只需给.dropdown-toggle
导航栏的高度,因此根据您的代码,您应该添加:
.dropdown-toggle {
height: 70px; /*cause 70px is the height of the navbar*/
}