.top{height: 100px;background:gray;}
.main{height: 800px; background:red; }
.left{width:200px;height: 800px;float:left;background:blue;}
.right{height: 800px;position:absolute;left:0;top:100px;right:0;background:green;margin:0 0 0 210px;}
.foot{height: 100px;background:gray;}
.main{height: 800px; background:red; }
.left{width:200px;height: 800px;float:left;background:blue;}
.right{height: 800px;position:absolute;left:0;top:100px;right:0;background:green;margin:0 0 0 210px;}
.foot{height: 100px;background:gray;}
上面的代碼沒有給main設置高度,而main里的內容又設置成了浮動,所以footer會跑到head的下面。
解決方法有3個:1.清除浮動, clear:both;
2.為main設置高度, .main{
width:860px;height:600px;margin:0 auto;background:#9FC;
}
3 footer自己設置margin高度600px:
.footer{ height:50px; background:#9F9; margin:600px 0 0 0;}
解決方法有3個:1.清除浮動, clear:both;
2.為main設置高度, .main{
width:860px;height:600px;margin:0 auto;background:#9FC;
}
3 footer自己設置margin高度600px:
.footer{ height:50px; background:#9F9; margin:600px 0 0 0;}
右側(right)先加載,左側(left)后加載其實就是右側的寫在前面,這時就不能用float了,老師想考察你們絕對定位position:absolute
.top{ height:100px; background:#ccc;}
.main{ height:500px; background:red;}
.left{ width:200px; height:500px; background:blue; position:absolute; left:0; top:100px;}
.right{ height:500px; background:green; margin-left:210px;}
.foot{ height:50px; background:#900;}
.main{ height:500px; background:red;}
.left{ width:200px; height:500px; background:blue; position:absolute; left:0; top:100px;}
.right{ height:500px; background:green; margin-left:210px;}
.foot{ height:50px; background:#900;}