我有这个菜单栏:http://jsfiddle.net/Qn3kh/1/
代码:
的CSS:
ul#menu {
position: absolute;
width: 100%;
min-width: 1180px;
height: 35px;
background-color: rgb(25, 25, 25);
text-align: center;
line-height: 2px;
}
#menuborders1{
position: absolute;
left: 0px;
right: 0px;
top: 6px;
bottom: 6px;
border-top: 3px solid rgb(30, 174, 206);
border-bottom: 3px solid rgb(30, 174, 206);
}
#menuborders2{
position: absolute;
left: 0px;
right: 0px;
top: 5px;
bottom: 5px;
border-top: 1px solid rgb(255, 136, 0);
border-bottom: 1px solid rgb(255, 136, 0);
}
ul#menu li {
display: inline-block;
margin-right: -3px;
}
ul#menu li a {
position: relative;
text-decoration: none;
font-family: Arial;
padding: 10px 75px 7px 75px;
color: #fff;
}
ul#menu li.current a {
color: rgb(25, 25, 25);
background-color: #1EAECE;
}
ul#menu li a:hover {
color: rgb(25, 25, 25);
background-color: #FF8800;
}
HTML:
<ul id="menu">
<div id="menuborders1">
<div id="menuborders2">
<li class="current"><a href="#" data-id="div1">Description</a></li>
<li><a href="#" data-id="div2">Shipping and payment</a></li>
<li><a href="#" data-id="div3">Returns</a></li>
<li><a href="#" data-id="div4">Feedback</a></li>
</div>
</div>
</ul>
你可以看到,当悬停在活动按钮上时,css会改为:悬停样式,我希望它不会改变,活动按钮得到它的风格,悬停得到它的风格
答案 0 :(得分:2)
更新了css:
ul#menu li:not(.current) a:hover{
color: rgb(25, 25, 25);
background-color: #FF8800;
}
而不是
ul#menu li a:hover{
color: rgb(25, 25, 25);
background-color: #FF8800;
}
答案 1 :(得分:1)
有你的答案伙伴:)
添加了以下css:
ul#menu li.current a,
ul#menu li.current a:hover{
color: rgb(25, 25, 25);
background-color: #1EAECE;
}