我需要将这个纯 CSS 下拉菜单修改为下拉菜单。看到一个类似的帖子,但似乎无法修改我的。这是用于下拉菜单的 css 代码,它按预期工作。我尝试使用bottom: 100%
within ul.drop li.hover, ul.drop li:hover {
,但没有奏效。有什么建议么。
HTML
<body>
<ul id="nav" class="drop">
<li><a href="#">Home</a></li>
<li>Portfolio
<ul>
<li><a href="#">Horses</a>
<ul>
<li><a href="#">Horses 1</a>
<li><a href="#">Horses 2</a>
<li><a href="#">Horses 3</a>
</ul>
</li>
<li><a href="#">Dogs</a></li>
<li><a href="#">People</a></li>
<li><a href="#">Stills</a></li>
</ul>
</li>
<li><a href="#">Order</a></li>
<li><a href="#">Contact Me</a>
</li>
</ul>
</li>
</ul>
CSS
ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
}
ul li {
display: block;
position: relative;
float: left;
width: 130px;
text-align: center;
}
li ul {
display: none;
}
ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 0px solid #ffffff;
padding: 0px 0px 0px 0px;
background: transparent;
# margin-left: 1px;
white-space: nowrap;
}
ul li a:hover {
background: transparent;
}
li:hover ul {
display: block;
position: absolute;
}
li:hover li {
float: none;
font-size: 11px;
width: 160px;
text-align: left;
}
li:hover a { background: transparent; }
li:hover li a:hover {
background: #3ba110;
}
ul.drop a {
display:block; color: #fff; font-family: Verdana; font-size: 14px; text-decoration: none;
}
ul.drop, ul.drop li, ul.drop ul {
list-style: none; margin: 0; padding: 0; border: 1px solid #fff; background: #1302CB; color: #fff;
}
ul.drop {
position: relative; z-index: 597; float: left;
}
ul.drop li {
float: left; line-height: 1.3em; vertical-align: middle; zoom: 1; padding: 5px 10px;
}
ul.drop li.hover, ul.drop li:hover {
position: relative; z-index: 599; cursor: default; background: #3ba110;
}
ul.drop ul {
visibility: hidden; position: absolute; bottom: 100%; left: 0; z-index: 598; width: 160px; background: #cccccc; border: 1px solid #fff;
}
ul.drop ul li {
float: none;
}
ul.drop ul ul {
top: -2px; left: 100%;
}
ul.drop li:hover > ul {
visibility: visible
}