我正在尝试创建一个下拉菜单,但是每当我将鼠标悬停在父菜单上时,子菜单都不会与之对齐。我经历了很多例子,我总是得到相同的结果。
我的 CSS 代码是
#mainNav {
margin-top: 20px;
width: 800px;
margin-left: auto;
margin-right: auto;
padding: 0;
overflow: hidden;
background-color: #BBFFFF;
zoom: 1;
}
#mainNav li {
float: left;
list-style: none;
}
#mainNav li a {
color: #000000;
display: block;
width: 80px;
font-size: 14px;
text-align: center;
text-transform: uppercase;
text-decoration: none;
padding: 7px 0px 7px 0px;
border-right: 1px solid #999;
zoom: 1;
}
#mainNav li ul {
display: none;
}
#mainNav a:hover {
background-color: #66FF66;
}
#mainNav li:hover ul {
display: block;
position: absolute;
}
#mainNav li:hover li {
float: left;
width: 80px;
background-color: #BBFFFF;
margin: 0;
padding: 0;
}
我的 HTML 是
<div>
<ul id="mainNav">
<li><a href="pageone.html" id="pageOneLink">Page One</a></li>
<li><a href="pagetwo.html" id="pageTwoLink">Page Two</a></li>
<li><a href="pagethree.html" id="pageThreeLink">Page Three</a>
<ul>
<li><a href="threePageOne.html" name="threePageOneLink>Sub Page One</a></li>
</ul>
</li>
</ul>
</div>