我正在尝试构建一个非常简单的下拉菜单。我希望所有 li 的高度都为 60 像素。我已经为下拉菜单使用了一些不同的教程,但我一直遇到同样的问题。我无法让“Link 1”完全清除“Drop 1”。它会清除锚点,但不会清除 li 本身。
<nav>
<ul id="nav">
<li><a href="#">Drop 1</a>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
</li>
<li><a href="#">Drop 2</a>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
</li>
</ul>
</nav>
CSS:
a {
color: #333;
}
nav {
width: 992px;
height: 50px;
margin: 0 auto;
border: 1px solid #ebebeb;
background: red;
}
#nav {
width: 992px;
margin: 0 auto;
line-height: 100%;
}
#nav li {
float: left;
position: relative;
list-style: none;
}
/* main level link */
#nav a {
width: 280px;
font-weight: bold;
color: #e7e5e5;
text-decoration: none;
display: block;
padding: 16px 20px;
margin: 0;
border: 1px solid white;
}
/* main level link hover */
#nav .current a, #nav li:hover > a {
background: blue;
}
/* level 2 list */
#nav ul {
display: none;
margin: 0;
padding: 0;
position: absolute;
top: 35px;
left: 0;
background: #f5f5f5;
}
/* dropdown */
#nav li:hover > ul {
display: block;
}
#nav ul li {
float: none;
margin: 0;
padding: 0;
}
#nav ul a {
font-weight: normal;
}
/* clearfix */
#nav:after {
content: "";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
#nav {
display: inline-block;
}
html[xmlns] #nav {
display: block;
}
* html #nav {
height: 1%;
}