代码如下:
<!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>常见的网页布局</title>
<style>
*{
margin: 0;
padding: 0;
}
.top{
height: 50px;
background-color: aquamarine;
margin-bottom: 10px;
}
.banner{
height: 100px;
width: 1000px;
background-color: palegoldenrod;
margin: 0 auto;
margin-bottom: 10px;
}
.box1{
height:80px;
width:1000px;
margin: 0 auto;
background-color: gray;
margin-bottom: 10px;
}
.box1 div{
background-color:palevioletred;
float: left;
height: 80px;
width:242.5px;
margin-right: 10px;
}
.box1 .last1{
margin-right: 0;
}
.box2{
height:120px;
width:1000px;
margin: 0 auto;
background-color: gray;
margin-bottom: 10px;
}
.box2 div{
background-color:green;
float: left;
height: 120px;
width:242.5px;
margin-right: 10px;
}
.box2 .last2{
margin-right: 0;
}
.footer{
height: 100px;
background-color: indigo;
}
</style>
</head>
<body>
<div class="top"> </div>
<div class="banner"></div>
<div class="box1">
<div>1</div>
<div>2</div>
<div>3</div>
<div class="last1">4</div>
</div>
<div class="box2">
<div>1</div>
<div>2</div>
<div>3</div>
<div class="last2">4</div>
</div>
<div class="footer"></div>
</body>
</html>