注意main的代碼中margin:0 310 0 210 需在310以及210后加上px,變成margin:0 310px 0 210px才會產生10px的邊框以及自適應文字不會覆蓋掉文字
.top{width:100%;height:200px;background:#ccc;}
.main{width:100%;height:600px;background:red;}
.left{width:200px;height:600px;background:#00f;position:absolute;left:0;top:200px;}
.right{height:600px;background:#9f9;margin-left:210px;}
.foot{width:100%;height:150px;background:#f60;}
.main{width:100%;height:600px;background:red;}
.left{width:200px;height:600px;background:#00f;position:absolute;left:0;top:200px;}
.right{height:600px;background:#9f9;margin-left:210px;}
.foot{width:100%;height:150px;background:#f60;}
最新回答 / 慕神2768241
你的父元素main沒加高度?如果不想添加高度,那么讓foot清除浮動( clear:both; )也可以,至于為什么要清除浮動,自己上網查查,因為我也是個初學者。。。
2018-05-02
最贊回答 / 楓芒i
footer 的色塊已經跑到了上面,只有文字在下面,之所以會跑走,是因為上面的元素用了浮動,原來的位置就空了出來,然后 footer 沒有浮動元素,又沒有清除浮動,就占據了中間位置,所以,想讓footer 在他自己的位置,就先清除浮動(clear:both)希望幫到你~....footer{ height:50px; background:#9F9; clear:both;}
2018-05-02