在以下示例中 - 悬停在子元素上时是否可以保留顶级导航的边框?当悬停在其子项目上时,我想保留“关于我们”的黑色边框。示例:http: //jsfiddle.net/6zKRC/2/
HTML
<div class="navigation">
<ul class="navigation fc">
<li>
<a href="/">Home</a>
</li>
<li class="">
<a href="/about.aspx">About</a>
<ul>
<li>
<a href="/about/sub-navigation-1.aspx">Sub Navigation 1</a>
</li>
<li>
<a href="/about/sub-navigation-2.aspx">Sub Navigation 2</a>
</li>
</ul>
</li>
</ul>
</div>
CSS
.navigation ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
}
.navigation ul li {
display: block;
position: relative;
float: left;
}
.navigation li ul {
display: none;
}
.navigation ul li a {
display: block;
text-decoration: none;
color: #000;
font-weight:bold;
padding: 5px 15px 5px 15px;
white-space: nowrap;
}
.navigation ul li a:hover {
background: #CCC;
color:black;
border:solid 1px black;
border-bottom:0;
}
.navigation li:hover ul {
display: block;
position: absolute;
border:solid 1px black;
border-top:0;
}
.navigation li:hover li {
float: none;
font-size: 11px;
}
.navigation li:hover a {
background: #CCC;
}
.navigation li:hover li a:hover {
background: #CCC;
border:0;
}
</p>