.top{height:100px;background:#ccc;margin:0 auto}.main{height:600px;background:red;position:relative}.left{ height: 600px; width:200px; background: blue;? ? positive:absolute;top:0;left:0}.right{ height: 600px; width:100%; background: green; position:absolute; margin-left:210px; }.foot{height:50px;background:#F63;}
2 回答

淵翼
TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超0個(gè)贊
width: 100%也就是說寬度跟父元素一樣寬,然后又加了一個(gè)margin-left:210px,結(jié)果所以就超出父元素啦。
所以可以把.right的樣式修改一下,最終代碼如下:
.top{ ??height:?100px; ??background:?#ccc; } .main{ ??height:?600px; ??background:?red; ??position:?relative } .left,?.right?{ ??position:?absolute; ??top:?0; ??height:?100%; } .left{ ??width:?200px; ??background-color:?blue; ??left:?0 } .right{ ??background-color:?green; ??left:?210px; ??right:?0; } .foot{ ??height:?50px; ??background:?#F63; }
添加回答
舉報(bào)
0/150
提交
取消