我正在尝试为大学网站创建垂直菜单栏。我在实现子级别列表的显示时遇到问题。我当前的代码产生了非常奇怪的结果。我该如何纠正?
HTML 代码:
<div class="nav">
<ul class="top-level">
<li><a href="#">EME Alumni</a></li>
<li>
<a href="#">Alumni Reunion 2012</a>
<ul class="sub-level">
<li><a href="#">RSVP</a></li>
<li><a href="#">Organizing Team</a></li>
</ul>
</li>
<li>
<a href="#">Alumni Reunion 2012</a>
<ul class="sub-level">
<li><a href="#">RSVP</a></li>
<li><a href="#">Organizing Team</a></li>
</ul>
</li>
</ul>
</div>
CSS是:
.nav {
margin: 3%;
width: 225px;
float: left;
}
.nav ul{list-style: none;margin:0;}
.nav a {
float: left;
list-style: none;
display:block;
text-decoration: none;
font-size: 1.25em;
color: #696969;
padding: 10px;
width: 225px;
position: relative;
background: -webkit-gradient(linear, left top, left bottom, from(#A9A9A9), to(#C0C0C0));
}
.nav a:hover {background: -webkit-gradient(linear, left top, left bottom, from(#C0C0C0), to(#A9A9A9));}
ul.sub-level {
margin-left: 110%;
display:none;
}
li:hover .sub-level {
display: block;
}
</p>