css3学习——一列固定宽度且居中

<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="UTF-8">
<style>
*{
margin: 0;
padding: 0;
}
/*相同的样式我们可以使用并集选择器*/
.top,
.banner,
.main,
.footer {
width: 960px;
margin: 0 auto;
margin-bottom: 10px;
text-align: center;
}
.top{
height: 80px;
background-color: pink;
}
.banner{
height: 120px;
background-color: #0a2ffe;
}
.main{
height: 500px;
background-color: hotpink;
}
.footer{

height: 150px;
background-color:black;
}
</style>
<title>Title</title>
</head>
<body>
<div class="top">top</div>
<div class="banner">banner</div>
<div class="main">main</div>
<div class="footer">footer</div>

</body>
</html>
posted @ 2019-11-30 17:17  菜鸟不忘初心  阅读(562)  评论(0编辑  收藏  举报