<body>
<div class="head">head</div>
<div class="main">main</div>
<div class="footer">footer</div>
</body>
</html>
DEMO:http://Lovejulyer.github.io/Source_Code/Blog_demo/Codes2/yilieguding.html
一列布局自适应:
XML/HTML Code复制内容到剪贴板
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>一列布局</title>
<style>
body{ margin:0; padding:0; font-size:30px; font-weight:bold}
div{ text-align:center; line-height:50px}
.head, .main, .footer{width:80%;margin:0 auto} /*margin属性及定宽为百分比*/
.head{ height:100px; background:#ccc}
.main{ height:600px; background:#FCC}
.footer{ height:50px; background:#9CF}
</style>
</head>
<body>
<div class="head">head</div>
<div class="main">main</div>
<div class="footer">footer</div>
</body>
</html>
DEMO:http://Lovejulyer.github.io/Source_Code/Blog_demo/Codes2/yiliezishiying.html
三、横向两列布局
浮动布局:CSS中规定的第二种定位机制;能够实现横向多列布局;通过设置float属性实现。
float属性:left | right | none
特点:元素会左移,或右移,直至触碰到容器为止。
注:设置了浮动的元素,仍旧处于文档流中。当元素没用设置宽度值。若设置了浮动属性,元素的宽度随内容的变化而变化。当元素设置浮动属性后,会对相邻的元素产生影响,相邻元素特指相邻后面的元素。
清除浮动的方法:
clear属性——常用clear:both;clear:left;或者clear:right;同时设置width:100%(或固定宽度)+overflow:hidden;










