<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
body {
background-color: rgb(223, 223, 223);
}
.word {
font-size: 15px;
text-align: left;
height: 30px;
background-color: blanchedalmond;
padding-left: 20px;
line-height: 31px;
}
.city {
width: 50px;
background-color: rgb(233, 203, 158);
padding-left: 20px;
}
.city:hover {
background-color: white;
}
/* 城市div下一个紧挨着的DIV中,CSS设置为显示 */
.city:hover + .list {
display: block;
}
/* 城市列表*/
.list {
background-color: rgb(255, 255, 255);
width: 300px;
margin-top: -15px;
display: none;
/* 默认隐藏 */
}
/* 鼠标移入,不消失 */
.list:hover {
display: block;
}
</style>
<body>
<div class="word">
<div class="city">
北京
</div>
<div class="list">
<ul>
<li><a href="baidu">河北</a></li>
<li><a>河南</a></li>
<li><a>北京</a></li>
<li><a>天津</a></li>
</ul>
</div>
</div>
</body>
</html>