html笔记 横向两列布局

 

<!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>
</head>
<style type="text/css">
*{margin:0;padding:0;}
#wrap{width:960px;margin:0 auto;background:#00C;}

#header{background:#FF3300;width:100%;}
#mainbody{background:#FC0;width:100%;overflow:hidden;

}
.left{width:820px;height:400px;background:#36C;float:left;margin-right:20px;}
.right{width:120px;height:600px;background:#0F3;float:right;}
#footer{background:#60C;clear:
both;}
</style>
<body>
<div id="wrap">
<div id="header">头部</div>
<div id="mainbody">
<div class="left">left</div>
<div class="right">right</div>

</div>
<div id="footer"> 脚注</div>
</div>

</body>
</html>

浮动会动mainbody和footer影响,分别采取
1.width:100%;overflow:hidden;
2.clear:both;
posted @ 2016-11-19 21:52  一米阳光!  阅读(1638)  评论(0编辑  收藏  举报