这是我第一次尝试使用css下拉菜单。我以前从未这样做过,并且已经遇到过问题。菜单下降很好,应该是红色。 (它是),但第一个采取bg图像而不是它下面的红色bg。请在jsfiddle中查看此代码,并告诉我如何修复它。
<html>
<head>
<link rel='stylesheet' type='text/css' href='css/styles.css' />
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'> </script>
</head>
<body>
<div id='cssmenu'>
<ul>
<li><a href='index.html'><span>Home</span></a></li>
<li><a href='team'><span>Team</span></a>
<ul>
<li><a href='team'>Team</a></li>
<li><a href='team'>Team2</a></li>
<li><a href='team'>Team3</a></li>
</ul>
</li>
<li><a href='sponsors'><span>Sponsors</span></a></li>
<li><a href='first'><span>First</span></a></li>
<li><a href='contact-us'><span>Contact Us</span></a></li>
<li class='last'><a href='handouts'><span>Handouts</span></a></li>
</ul>
</div>
</body>
</html>
和CSS:
#cssmenu ul {
list-style-type: none;
position: relative;
display: block;
font-size: 12px;
background: url(../images/bg.png) repeat-x top left;
font-family: Verdana, Helvetica, Arial, sans-serif;
border: 1px solid #000;
margin: 0;
padding: 0;
width: auto;
}
#cssmenu li {
display: inline-block;
margin: 0;
padding: 0;
}
#cssmenu li ul {
position: absolute;
display: none;
}
#cssmenu li ul li {
display: block;
}
#cssmenu li:hover ul {
display: block;
}
#cssmenu li a {
display: block;
color: #A79787;
text-decoration: none;
padding: 9px 15px;
font-weight: normal;
}
#cssmenu li a:hover,
#cssmenu .active {
color: #fff;
background: url(../images/bg.png) repeat-x top left;
text-decoration: none;
}
#cssmenu .active a {
color: #fff;
font-weight: 700;
}
#cssmenu ul {
background-color: #B11718;
}
#cssmenu li a:hover,
#cssmenu li.active {
background-color: #DE3330;
}
很高兴你能全部帮助我。感谢。
答案 0 :(得分:0)
将背景颜色更改为背景,以便覆盖以前的样式。
#cssmenu li a:hover,
#cssmenu li.active {
background: #DE3330;
}