赞
踩
为了提高网页制造的效率,布局时通常需要遵守一定的布局流程,具体如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
* {
margin: 0;
padding: 0; /* 清除内外边距 css 第一讲句话 */
}
/* 相同的样式,我们会想到 并集选择器 */
.top,
.banner,
.main,
.footer {
width: 960px;
text-align: center; /* 文字居中对齐 */
margin: 0 auto; /* 可以让盒子居中对齐 只要保证 左右auto就阔以了 */
margin-bottom: 10px;
border: 1px dashed #ccc;
}
.top {
height: 80px;
background-color: pink;
}
.banner {
height: 120px;
background-color: purple;
}
.main {
height: 150px;
background-color: hotpink;
}
.footer {
height: 250px;
background-color: black;
}
</style>
</head>
<body>
<div class="top">top</div>
<div class="banner">banner</div>
<div class="main">main</div>
<div class="footer">footer</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
.top,
.banner,
.main,
.fotter{
width: 960px;
margin: 0 auto;
border: 1px dashed red;
text-align: center;
background-color: pink;
}
.top{
height: 80px;
}
.banner{
height: 100px;
}
.main{
height: 140px;
}
.left{
width: 360px;
height: 140px;
background-color: hotpink;
float: left;
}
.right{
width: 592px;
height: 140px;
background-color: hotpink;
float: right;
}
.fotter{
height: 200px;
}
</style>
</head>
<body>
<div class="top">top</div>
<div class="banner">banner</div>
<div class="main">
<div class="left">left</div>
<div class="right">right</div>
</div>
<div class="fotter">fotter</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.top{
/* 通栏的盒子,可以不用写宽度,默认的宽度和浏览器一样宽 */
height: 80px;
border: 1px dashed #aaa;
background-color: #eee;
text-align: center;
}
.banner{
width: 960px;
height: 100px;
border: 1px dashed #aaa;
background-color: #eee;
text-align: center;
margin: 10px auto;
}
.small{
width: 960px;
height: 80px;
background-color: #eee;
margin: 10px auto;
}
ul{
list-style: none;
}
.small ul li{
width: 230px;
height: 80px;
border: 1px dashed #aaa;
background-color: pink;
float: left;
margin-left: 10px;
}
.small .no{
margin-left: 0;/* 权重问题 */
}
.fotter{
height: 100px;
border: 1px dashed #aaa;
background-color: #eee;
text-align: center;
}
</style>
</head>
<body>
<div class="top">通栏的顶部</div>
<div class="banner">广告条</div>
<div class="small">
<ul>
<li class="no">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
<div class="small">
<ul>
<li class="no">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
<div class="small">
<ul>
<li class="no">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
<div class="fotter"></div>
</body>
</html>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。