.top{height:100px;background:gray;}
.main{height:500px;background:red;margin:0 auto;position:relative;}
.left{height:500px;width:200px;background:blue;position:absolute;top:0px;}
.right{height:500px;width:100%px;background:green;margin-left:210px;}
.foot{height:50px;background:orange;margin:0 auto;}
.main{height:500px;background:red;margin:0 auto;position:relative;}
.left{height:500px;width:200px;background:blue;position:absolute;top:0px;}
.right{height:500px;width:100%px;background:green;margin-left:210px;}
.foot{height:50px;background:orange;margin:0 auto;}
.top{width:100%;height:60px;background:#ccc}
.main{margin:0 auto;height:600px; background:red}
.left{width:20%; height:600px;margin:0px 81% 0px 0px; background:blue; position:absolute;}
.right{width:80%;margin:0px 0px 0px 21%; height:600px;background:#9C9; position:absolute;}
.main{margin:0 auto;height:600px; background:red}
.left{width:20%; height:600px;margin:0px 81% 0px 0px; background:blue; position:absolute;}
.right{width:80%;margin:0px 0px 0px 21%; height:600px;background:#9C9; position:absolute;}
.top{width:100%;background:#ccc;}
.main{height:500px;width:100%;background:red;position:relative;}
.left{width:200px;height:100%;background:blue;position:absolute;}
.right{margin-left:210px;width:100%;position:absolute;height:100%;background:green;}
.foot{width:100%;background:orange;}
.main{height:500px;width:100%;background:red;position:relative;}
.left{width:200px;height:100%;background:blue;position:absolute;}
.right{margin-left:210px;width:100%;position:absolute;height:100%;background:green;}
.foot{width:100%;background:orange;}
margin:0px 310px 0 210px;我这么设置结果main还是水平居于下方,在自己的编辑器里把margin-top:-600,才最后实现这样的效果。我看别人的答案都是margin:0px 310px 0 210px;我就是没办法实现那样的效果。
---------------
margin:0px 310px 0 210px; 分别设置 上0px 右310px 下0px 左210px 发现问题没有 上和下都为0px的话.main就会在下方 把margin:0px 310px 0 210px;改为margin:0px 310px auto 210px;问题就解决了
---------------
margin:0px 310px 0 210px; 分别设置 上0px 右310px 下0px 左210px 发现问题没有 上和下都为0px的话.main就会在下方 把margin:0px 310px 0 210px;改为margin:0px 310px auto 210px;问题就解决了
{width:800px;height:50px;margin:0 auto;background:gray}
{width:800px;height:400px;margin:0 auto;background:red}
{width:290px;height:400px;float:left;background:#0737F6}
{width:490px;height:400px;float:right;background:#64EBD4}
{width:800px;height:25px;background:#E78B42;clear:both;margin:0 auto;}
{width:800px;height:400px;margin:0 auto;background:red}
{width:290px;height:400px;float:left;background:#0737F6}
{width:490px;height:400px;float:right;background:#64EBD4}
{width:800px;height:25px;background:#E78B42;clear:both;margin:0 auto;}
.top{height:80px;width:100%;background:gray;}
.main{height:500px;width:100%;background:red;position:relative;}
.left{height:500px;width:40%;position:absolute;background:blue;left:0;top:0;}
.right{height:500px;width:58%;background:#9c9;float:right;}
.foot{height:40px;width:100%;background:#f63;}
.main{height:500px;width:100%;background:red;position:relative;}
.left{height:500px;width:40%;position:absolute;background:blue;left:0;top:0;}
.right{height:500px;width:58%;background:#9c9;float:right;}
.foot{height:40px;width:100%;background:#f63;}
顶部、底部都好弄,这里只说下中间主体部分代码:
.main{width:100%; height:400px; background:red; position:relative;} 注(参照定位的元素必须加入“position:relative”,否则下面绝对定位会出问题。)
.left{width:200px; height:400px; background:blue; position:absolute; top:0; left:0;}
.right{margin-left:210px; width:100%; height:400px; background:green;}
.main{width:100%; height:400px; background:red; position:relative;} 注(参照定位的元素必须加入“position:relative”,否则下面绝对定位会出问题。)
.left{width:200px; height:400px; background:blue; position:absolute; top:0; left:0;}
.right{margin-left:210px; width:100%; height:400px; background:green;}
.top{height:200px; background:grey;}
.main{height:600px;background:red;}
.left{height:600px;width:200px; background:blue; position:absolute;}
.right{height:600px;width:100%; background:green; margin:0 0 0 210px;position:absolute;}
.foot{height:100px; background:orange; clear:both;}
.main{height:600px;background:red;}
.left{height:600px;width:200px; background:blue; position:absolute;}
.right{height:600px;width:100%; background:green; margin:0 0 0 210px;position:absolute;}
.foot{height:100px; background:orange; clear:both;}
.top{width:100%;height:100px;background:gray;}
.main{width:100%;height:600px;background:red;}
.right{height:600px;background:green;margin:0 0 100px 210px;}
.left{width:200px;height:600px; background:blue;position:absolute;left:0; top:100px;}
.foot{width:100%;height:100px;background:yellow;}
.main{width:100%;height:600px;background:red;}
.right{height:600px;background:green;margin:0 0 100px 210px;}
.left{width:200px;height:600px; background:blue;position:absolute;left:0; top:100px;}
.foot{width:100%;height:100px;background:yellow;}