注意:
margin:0 auto;/**0:上下 auto:左右**/
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{
margin:0;
padding:0;
}
#wrap{
width:800px;
margin:0 auto;
border:3px solid yellow;
}
#header{
width:100%;
border:3px solid red;
}
#main{
width:100%;
border:3px solid green;
}
#footer{
width:100%;
border:3px solid grey;
}
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div>this is header</div>
</div>
<div id="main">
<div>this is main</div>
<div>red</div>
<div>red</div>
</div>
<div id="footer">
<div>this is footer</div>
</div>
</div>
</body>
</html>