标记
<div class="dropdown" style="background-color: white;" tabindex="1">
<a>Menu</a>
<ul>
<li>
<a>Fruits</a>
<ul>
<li><a>Apple</a></li>
<li><a>Orange</a></li>
<li><a>Grape</a></li>
<li><a>Banana</a></li>
</ul>
</li>
<li>
<a>Vegetables</a>
<ul>
<li><a>Lemon</a></li>
<li><a>Cucumber</a></li>
<li><a>Melon</a></li>
</ul>
</li>
</ul>
</div>
css
.dropdown {
position: relative;
display: inline-block;
font-size: 110%;
}
.dropdown ul {
position: absolute;
top: -100%;
left: 100%;
display: none;
background-color: inherit;
padding: 0;
list-style: none;
border: 1px solid #ccc;
}
.dropdown ul li {
position: relative;
list-style: none;
margin: 5px 0;
background-color: inherit;
}
.dropdown ul li a {
display: block;
padding: 3px 10px;
}
.dropdown ul li a:hover {
background-color: #18b6f2 !important;
}
.dropdown ul li:hover > ul {
display: block;
top: 0;
background-color: inherit;
}
.dropdown ul li:hover > a {
background-color: #85ddff;
}
.dropdown:hover > ul {
display: block;
}
这将满足您的需求。它是可扩展的。您可以使用任意数量的子级别。