这是我第一次尝试 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;
}
希望你们都可以帮助我。谢谢。