abstract:<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>导航栏</title> <link rel="styles
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>导航栏</title>
<link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
<style>
*{
margin: 0;
padding: 0;
}
a{
text-decoration: none;
font-size: 14px;
font-family: Consolas, "Liberation Mono", Courier, "微软雅黑";
color: #262927;
}
ul{
width: 100px;
display: none;
border: 1px solid #eaeff4;
border-top: none;
position: absolute;
left: 0;
}
li{
padding: 3px 5px;
list-style: none;
}
.header{
width: 100%;
height: 40px;
background-color: #eaeff4;
}
.nav{
width: 70%;
height: 40px;
line-height: 40px;
margin: 0 auto;
}
.nav_left{
width: 70%;
height: 40px;
float: left;
}
.nav_right{
width: 30%;
height: 40px;
float: right;
}
.nav a{
position: relative;
display: inline-block;
padding: 0 20px;
transition: 0.5s;
}
.nav a:hover{
border-bottom: 1px solid #b21f2d;
background-color: #ffffff;
}
.nav a:hover ul{
display: block;
}
.nav ul li:hover{
background-color: #eaeff4;
}
</style>
</head>
<body>
<div class="header">
<div class="nav">
<div class="nav_left">
<a href="">探索</a>
<a href="">题库
<ul>
<li>C</li>
<li>C++</li>
<li>Java</li>
<li>Python</li>
</ul>
</a>
<a href="">竞赛</a>
<a href="">阅读</a>
<a href="">社区</a>
<a href="">商店
<ul>
<li>商品1</li>
<li>商品2</li>
<li>商品3</li>
<li>商品4</li>
</ul>
</a>
</div>
<div class="nav_right">
<a href="">登陆</a>
<a href="">注册</a>
</div>
</div>
</div>
<div style="clear: both;"></div>
</body>
</html>
演示地址 -> http://47.107.64.136/CSS/2/
Correcting teacher:天蓬老师Correction time:2019-01-13 09:32:07
Teacher's summary:代码是我喜欢的风格不错, 美中不足是后面的清浮动,不够优雅:<div style="clear: both;"></div>, 让页面中多了一个无用的家伙,你可以通过伪类做到:after