利用伪类来做,话不多说直接上代码
<!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>
<style>
*{
margin: 0;
padding: 0;
}
nav{
width: 1200px;
height: 100px;
line-height: 100px;
margin:0 auto;
}
section{
float: left;
margin:0 30px;
position: relative;
}
/* 我们先加上 伪类 模拟的边框 */
section::after{
content: "";
width: 100%;
height: 1px;
background: red;
position: absolute;
left: 0;
bottom: 5px;
}
</style>
</head>
<body>
<nav>
<section>首页</section>
<section>首页</section>
<section>首页</section>
<section>首页</section>
<section>首页</section>
<section>首页</section>
<section>首页</section>
</nav>
</body>
</html>