码迷,mamicode.com
首页 > Web开发 > 详细

css简单布局

时间:2017-12-02 14:12:15      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:文档   方向   宽度   tle   lin   content   未定义   line   color   

一列布局

宽度未定义则宽度为通栏的宽度

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>一列布局</title>
<style>
div{text-align: center;}
.head{height: 100px;background-color:red;}
.main{margin: 0 auto;height:500px;background-color:yellow;width: 80%;}
.foot{margin: 0 auto;background-color:blue;width:80%;}
</style>
</head>
<body>
<div class="head">head</div>
<div class="main">main</div>
<div class="foot">foot</div>
</body>
</html>

两列布局

<!--利用浮动或绝对定位去除文档样式-->

<!DOCTYPE html>
<html>
<head>
<title>二列布局</title>
<style>
body{ margin:0; padding:0; font-size:30px; font-weight:bold}
div{ text-align:center; line-height:50px}
.main{ width:80%; height:600px; margin:0 auto}
.left{ width:20%; height:600px; background:#ccc; float:left}
.right{ width:80%; height:600px; background:#FCC; float:right}
</style>
</head>
<body>
<div class="main">
<div class="left">left</div>
<div class="right">right</div>
</div>

</body></html>

三列布局

<!--CSS中的 margin 和 padding 都是顺时钟方向进行定义的-->

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>三列布局</title>
<style type="text/css">
body{ margin:0; padding:0; font-weight:bold}
div{ line-height:50px}
.left{ width:200px; height:600px; background:#ccc; position: absolute; left:0; top:0}
.main{ height:600px; margin:0 310px 0 210px; background:#9CF}
.right{ height:600px; width:300px; position:absolute; top:0;right:0;; background:#FCC;}
</style>
</head>
<body>
<div class="left">left</div>
<div class="main">main</div>
<div class="right">right</div>
</body>
</html>

css简单布局

标签:文档   方向   宽度   tle   lin   content   未定义   line   color   

原文地址:http://www.cnblogs.com/1001n/p/7953964.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!