.top{height: 100px;background:gray;}
.main{height: 800px; background:red; }
.left{width:200px;height: 800px;float:left;background:blue;}
.right{height: 800px;position:absolute;left:0;top:100px;right:0;background:green;margin:0 0 0 210px;}
.foot{height: 100px;background:gray;}
.main{height: 800px; background:red; }
.left{width:200px;height: 800px;float:left;background:blue;}
.right{height: 800px;position:absolute;left:0;top:100px;right:0;background:green;margin:0 0 0 210px;}
.foot{height: 100px;background:gray;}
上面的代码没有给main设置高度,而main里的内容又设置成了浮动,所以footer会跑到head的下面。
解决方法有3个:1.清除浮动, clear:both;
2.为main设置高度, .main{
width:860px;height:600px;margin:0 auto;background:#9FC;
}
3 footer自己设置margin高度600px:
.footer{ height:50px; background:#9F9; margin:600px 0 0 0;}
解决方法有3个:1.清除浮动, clear:both;
2.为main设置高度, .main{
width:860px;height:600px;margin:0 auto;background:#9FC;
}
3 footer自己设置margin高度600px:
.footer{ height:50px; background:#9F9; margin:600px 0 0 0;}
右侧(right)先加载,左侧(left)后加载其实就是右侧的写在前面,这时就不能用float了,老师想考察你们绝对定位position:absolute
.top{ height:100px; background:#ccc;}
.main{ height:500px; background:red;}
.left{ width:200px; height:500px; background:blue; position:absolute; left:0; top:100px;}
.right{ height:500px; background:green; margin-left:210px;}
.foot{ height:50px; background:#900;}
.main{ height:500px; background:red;}
.left{ width:200px; height:500px; background:blue; position:absolute; left:0; top:100px;}
.right{ height:500px; background:green; margin-left:210px;}
.foot{ height:50px; background:#900;}