.top{width:100%; height:50px;background:gray}
.main{width:100%; height:300px;background:red;position:relative}
.left{width:200px;height:300px;background:blue;position:absolute;top:0; left:0;}
.right{margin-left:210px;height:300px;background:green}
.foot{width:100%; height:50px;background:#369}
.main{width:100%; height:300px;background:red;position:relative}
.left{width:200px;height:300px;background:blue;position:absolute;top:0; left:0;}
.right{margin-left:210px;height:300px;background:green}
.foot{width:100%; height:50px;background:#369}
最赞回答 / __没有人
没有滚动条(即使加上overflow),不设置margin-left就有部分重叠,因为右侧默认与父容器等宽,换句话说,如果有滚动条,左侧你拉动的距离就是右侧盒子与父容器的宽差,就不满足等宽了
2017-03-26
属性排成顺眼的方式就容易发现问题啦!
*{ margin:0; padding:0;}
.left{ width:200px; height:600px; background:#ccc; position:absolute; left:0; top:0}
.main{ height:600px; margin:0 310px 0 210px; background:#9CF}
.right{ width:300px; height:600px; background:#FCC; position:absolute; top:0;right:0;}
</style>
*{ margin:0; padding:0;}
.left{ width:200px; height:600px; background:#ccc; position:absolute; left:0; top:0}
.main{ height:600px; margin:0 310px 0 210px; background:#9CF}
.right{ width:300px; height:600px; background:#FCC; position:absolute; top:0;right:0;}
</style>