CSS:二级菜单
html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/二级菜单.css">
</head>
<body>
<header class="header">
<ul class="topnav clearfix">
<li><a href="">Lorem.</a></li>
<li><a href="">Repellat!</a></li>
<li><a href="">Necessitatibus?</a></li>
<li>
<a href="">客户服务</a>
<div class="submenu">
<ul>
<li>Lorem.</li>
<li>Dolore.</li>
<li>Sed.</li>
<li>Excepturi.</li>
<li>Inventore.</li>
<li>Expedita.</li>
<li>Sunt.</li>
<li>At.</li>
<li>Nisi.</li>
<li>Tempore!</li>
</ul>
</div>
</li>
<li><a href="">At.</a></li>
</ul>
</header>
<div style=" background:lightblue;">
</div>
</body>
</html>
css:
.clearfix::after {
content: "";
display: block;
clear: both;
}
.header {
background: #e3e4e5;
color: #999;
height: 40px;
line-height: 40px;
position: fixed;
width: 100%;
left: 0;
top: 0;
}
.header .topnav>li {
float: left;
margin: 0 20px;
width: 150px;
text-align: center;
height: 40px;
box-sizing: border-box;
position: relative;
}
.header .topnav>li:hover{
background: #fff;
border: 2px solid #ccc;
border-bottom: none;
line-height: 36px;
background: #fff;
}
.header .topnav>li .submenu{
text-align: left;
line-height: 1.5;
width: 300px;
/* 不生成盒子 */
display: none;
border: 2px solid #ccc;
box-sizing: border-box;
position: absolute;
right: -2px;
background: #fff;
}
.header .topnav>li:hover .submenu{
display: block;
padding: 10px;
}
.header .topnav>li:hover::after{
content: "";
position: absolute;
width: 100%;
height: 5px;
background: red;
bottom: 0;
left: 0;
background: #fff;
}