.top{height:100; background:#ccc}
.main{width:1000px;height:300px;background:red;margin:0 auto;}
.left{ width:200px;height:300px;background:blue;float:left;}
.right{width:780px; height:300px; background:#FCC; float:right;}
.foot{height:100; background:orange;clear:both;}
.main{width:1000px;height:300px;background:red;margin:0 auto;}
.left{ width:200px;height:300px;background:blue;float:left;}
.right{width:780px; height:300px; background:#FCC; float:right;}
.foot{height:100; background:orange;clear:both;}
.top{height:100px; background:#ccc}
.main{height:500px; background:red; position:relative;}
.left{position:absolute;left:0;top:0; width:200px; height:500px; background:blue; }
.right{margin-left:210px;height:500px; background:#9C9;}
.foot{height:50px; background:#F63}
还是要多练
.main{height:500px; background:red; position:relative;}
.left{position:absolute;left:0;top:0; width:200px; height:500px; background:blue; }
.right{margin-left:210px;height:500px; background:#9C9;}
.foot{height:50px; background:#F63}
还是要多练
已采纳回答 / 迷途的马尔斯
你好好想想你.right相对移动是相对谁来移动?是不是应该相对老爸(.main)来相对定位?如果你设置absolute就脱离文本流了,就不是相对.main来定位了,是相对浏览器窗口来定位了
2015-12-26
.top{height:200px;background:#ccc;}
.main{height:300px;background:red;margin:0 auto;}
.left{ width:200px;height:300px;left:0px;top:200px;background:blue;position:absolute;}
.right{width:80%;height:300px;margin:0 0 0 210px;position:absolute;background:green;}
.foot{height:200px;background:orange;}
.main{height:300px;background:red;margin:0 auto;}
.left{ width:200px;height:300px;left:0px;top:200px;background:blue;position:absolute;}
.right{width:80%;height:300px;margin:0 0 0 210px;position:absolute;background:green;}
.foot{height:200px;background:orange;}
将left和right的顺序换一下,就不用加position:absolute来定位left了,但是要求先加载right,那么就只能用position:absolute来定位
.main{height:600px;magin:0 auto;background:#F00}
.left{ width:200px;height:600px;background:#00C;position:absolute;top:50px}
.right{margin-left:210px;height:600px;background:#3F9;}
.main{height:600px;magin:0 auto;background:#F00}
.left{ width:200px;height:600px;background:#00C;position:absolute;top:50px}
.right{margin-left:210px;height:600px;background:#3F9;}
.top{height:200px;background-color:blue;top:0;left:0;}
.main{height:600px;background-color:red;}
.left{width:200px;height:600px;float:left;background-color:yellow;}
.right{width:400px;height:600px;float:right;background-color:green;}
.foot{height:150px;background-color:#567;margin:0 auto;}
.main{height:600px;background-color:red;}
.left{width:200px;height:600px;float:left;background-color:yellow;}
.right{width:400px;height:600px;float:right;background-color:green;}
.foot{height:150px;background-color:#567;margin:0 auto;}