使用浮动和标准的父盒子搭配
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<style>
* {
margin:0;
padding:0;
}
li{
list-style:none;
}
.top{
height:50px;
background-color:gray;
margin:0 auto;
}
.banner {
width: 980px;
height: 150px;
background-color: gray;
margin: 10px auto;
}
.box {
width: 980px;
height: 300px;
background-color: pink;
margin: 0px auto;
}
.box li {
float:left;
width:237px;
height:300px;
background-color:gray;
margin-right:10px;
}
.box .last {
margin-right: 0;
}
.footer{
height:200px;
margin-top:10px;
background-color:gray;
}
</style>
</head>
<body>
<div class="top"></div>
<div class="banner"></div>
<div class="box">
<ul>
<li></li>
<li></li>
<li></li>
<li class="last"></li>
</ul>
</div>
<div class="footer"></div>
</body>
</html>
对应的图