最赞回答 / 噼里啪啦稀里哗啦啊啊啊
你设置的margin,是距离left这个div的上外边距为0,所以会下沉 应该加上position:absolute;top:0; 这样才是距离父级元素body的上外边距为0
2017-01-03
.top{width:100%;height:100px; background:#9CF;}
.main{height:300px;width:100%;background:blue;}
.right{height:300px;width:100%;background:red;position:absolute;left:210px;}
.left{width:200px;height:300px;background:yellow;position:absolute;left:0;}
.foot{width:100%;height:100px; background:#9CF;}
.main{height:300px;width:100%;background:blue;}
.right{height:300px;width:100%;background:red;position:absolute;left:210px;}
.left{width:200px;height:300px;background:yellow;position:absolute;left:0;}
.foot{width:100%;height:100px; background:#9CF;}
body{ margin:0; padding:0; font-size:30px;}
.top{height:100px; width:100%;}
.main{height:600px; width:100%;}
.left{height:600px; width:200px; float:left;}
.right{height:600px; width:100%; position:absolute; margin:0 0 0 210px;}/*margin可以改为left:210px;*/
.foot{height:50px; width:100%;}
.top{height:100px; width:100%;}
.main{height:600px; width:100%;}
.left{height:600px; width:200px; float:left;}
.right{height:600px; width:100%; position:absolute; margin:0 0 0 210px;}/*margin可以改为left:210px;*/
.foot{height:50px; width:100%;}
这里使用浮动更简单,计算right可以使用calc
.top{background:#ccc;height:100px;}
.main{background:red;height:400px;}
.left{background:#0000fe;height:400px;float:left;width:200px;}
.right{background:#9acc99;height:400px;float:right;width:calc(100% - 210px);}
.foot{background:#ff6634;height:50px;}
.top{background:#ccc;height:100px;}
.main{background:red;height:400px;}
.left{background:#0000fe;height:400px;float:left;width:200px;}
.right{background:#9acc99;height:400px;float:right;width:calc(100% - 210px);}
.foot{background:#ff6634;height:50px;}
.body{margin:0;
padding:0}
.top{height:100px;background:#CCCCCC}
.main{width:500px;height:500px;background:red;margin:0 auto;}
.left{width:200px;height:500px;float:left;background:blue;}
.right{height:500px;margin:0 0 0 210px;background:#99FFCC;}
.footer{height:100px;background:#FF6600;}
padding:0}
.top{height:100px;background:#CCCCCC}
.main{width:500px;height:500px;background:red;margin:0 auto;}
.left{width:200px;height:500px;float:left;background:blue;}
.right{height:500px;margin:0 0 0 210px;background:#99FFCC;}
.footer{height:100px;background:#FF6600;}
最新回答 / EricZoo
.top{background:#ccc;height:100px;}.main{background:red;height:600px;}.left{background:blue;height:600px;width:200px;}.right{background:yellow;height:600px;width:100%;left:210px;position:absolute;}.foot{background:orange;height:50px;}这是我测试的最少代码实现了,疑问或错误欢迎...
2016-12-28
最赞回答 / EliPec
个人认为:right和left是在main下的块状元素,属于块嵌套着块,当left设定了绝对定位后,right不设置宽度为自适应,所以宽度为main的宽度减去left的宽度。->我的答案,亲测无误。.top{width:100%;background:gray;height:50px;}.main{width:100%;background:red;height:500px;}.left{ width:30%;float:left; background:blue;height:500px;}.ri...
2016-12-27