我有一个引导导航:
<nav class="navbar navbar-default" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <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="#"><img src="img/logo.png"></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-right">
<li class="active"><a href="#">Home</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Neuigkeiten <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">News</a></li>
<li><a href="#">Events</a></li>
<li><a href="#">Galerie</a></li>
</ul>
</li>
<li><a href="#">Fahrzeuge</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Ausbildung <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Allgemein</a></li>
<li class="divider"></li>
<li><a href="#">Versehrten</a></li>
<li><a href="#">Fremdsprachig</a></li>
<li><a href="#">Ferien</a></li>
<li class="divider"></li>
<li><a href="#">Seminare</a></li>
</ul>
</li>
<li><a href="#">LKW</a></li>
</ul>
<!--<ul class="nav navbar-nav navbar-right">
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</li>
</ul>-->
</div>
<!-- /.navbar-collapse -->
并制作了一些悬停效果(我更改了背景颜色)。现在我希望下拉菜单也出现在悬停时。所以我添加了这个:
ul.nav li.dropdown:hover ul.dropdown-menu{
display: block;
margin-top:-1px;
}
但是现在如果鼠标离开主菜单项以单击现在打开的下拉菜单中的某些内容,它不再具有更改的背景颜色......(因为它不再集中?!?)
但是,即使鼠标在相应的下拉菜单中导航,我该怎么做才能使主菜单项保持焦点(保持悬停背景颜色)?