<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: aqua;
}
li{
float: left;
}
li a,
.dropbtn{
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color: green;
}
.dropdown{
display: inline-block;
}
.dropdown-content{
display: none;
position: absolute;
background-color: darkgray;
min-width: 125px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0,2);
}
.dropdown-content a {
color: white;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown:hover a:hover{
background-color: lightpink;
}
.dropdown:hover .dropdown-content{
display: block;
}
</style>
</head>
<body>
<ul>
<li><a href="CSS练习/2.html">CSS练习</a></li>
<li>
<div class="dropdown">
<a href="CSS练习/伪类.html">CSS伪类</a>
<div class="dropdown-content"><a href="#">CSS</a>
<a href="#">CSS练习</a>
<a href="#">CSS伪类</a>
</div>
</div>
</li>
<li><a href="CSS练习/选择器基本类型.html">CSS</a></li>
<li><a href="CSS练习/选择器基本类型.html">CSS</a></li>
<li><a href="CSS练习/选择器基本类型.html">CSS</a></li>
</ul>
</body>
</html>
练习选择器的混合使用和下拉悬停
使用容器元素(如 <div>)创建下拉内容,并在其中添加任何内容。
.dropdown-content
类保存实际的下拉菜单内容。