通过a标签的:hover状态完成
语法:.box > ul > li:hover > .er----------hover之前是一级菜单,之后是要显示的二级菜单
完整代码:
<!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>
<link rel="stylesheet" href="/CSS/reset.css">
<style>
.box {
width: 300px;
height: 25px;
}
a {
text-decoration: none;
color: #000;
}
/* 设置一级菜单 */
.box>ul>li {
width: 90px;
height: 25px;
text-align: center;
background-color: bisque;