老师,只在footer设置clear:both,mainbody中不设置overflow:hidden也可以的啊,这是为什么呢
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
* { margin: 0; padding: 0; }
#wrap { width: 960px; margin: 0 auto; background: red; }
#header { width: 100%; background: black; }
#mainbody { width: 100%; background: yellow;}
#left{width:800px; background:green;float:left;}
#right{width:140px; height:300px; background:blue;float:right;}
#footer{width:100%;background:pink;clear:both;}
</style>
</head>
<body>
<div id="wrap">
<div id="header">头部</div>
<div id="mainbody">
<div id="left">左边</div>
<div id="right">右边</div>
</div>
<div id="footer">版权部分</div>
</div>
</body>
</html>