首先清楚清除浏览器吗,默认的格式
设置ul的格式
子元素到父元素
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
.nav{
list-style: none;
background-color: lightblue;
width: 1000px;
margin: 50px auto;
overflow: hidden;
zoom: 0;
}
.nav li{
float: left;
width: 25%;
}
.nav a{
width: 100%;
display: block;
text-align: center;
padding: 5px;
text-decoration: none;
color: white;
font-weight: bold;
background-color: cornflowerblue;
}
.nav a:hover{
background-color: crimson;
}
</style>
</head>
<body>
<ul class="nav">
<li>
<a href="#">首页</a>
</li>
<li>
<a href="#">新闻</a>
</li>
<li>
<a href="#">联系</a>
</li>
<li>
<a href="#">关于</a>
</li>
</ul>
</body>
</html>