11.11flex布局导航
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body,header,nav,ul,li{
padding: 0;
margin: 0;
}
a{
text-decoration: none;
color: #fff;
font-size: 20px;
font-weight: 400;
}
header{
background: #666666;
}
nav{
width: 1200px;
margin: 0 auto;
height: auto;
/*position: relative;*/
}
nav>ul{
display: flex;
Justify-content:center;
align-items:center;
flex-grow:5;
position: relative;
}
nav>ul>li{
list-style: none;
/*width: 20%;*/
text-align: center;
padding: 30px 20px;
position: relative;
}
nav>ul>li:hover{
background: #888888;
}
nav>ul>li:hover>ul{
display: block;
}
nav>ul>li>ul{
display: none;
position: absolute;
left: 0;
top: 86px;
}
nav>ul>li>ul>li{
list-style: none;
background: #788888;
padding: 30px 20px;
border-bottom: 1px solid #000000;
color: #fff;
}
nav>ul>li>ul>li:hover{
background: #000000;
}
</style>
</head>
<body>
<header>
<nav>
<ul>
<li><a href="">首页</a></li>
<li>
<a href="">关于我们</a>
<ul>
<li><a href="">公司简介</a></li>
<li><a href="">公司荣誉</a></li>
</ul>
</li>
<li><a href="">新闻资讯</a></li>
<li><a href="">公益动态</a></li>
<li><a href="">联系我们</a></li>
</ul>
</nav>
</header>
</body>
</html>
效果图