有两个div,怎么让下面一个div随着上面div的内容增多而往下拉,上面div的内容减少,下面的div自动填充上去

下面的div不能覆盖住上面div的内容!求高手,谢谢!

第1个回答  2011-03-09
设定这两个层分别为x1和x2,宽度都为950像素,x1和x2的高度随各自的内容自动变化,x2可以自动适应x1。
<style type="text/css">
.x1{width:950px;height:auto;float:left;clear:both;}
.x2{width:950px;height:auto;float:left;clear:both;}
</style>
<div class="x1"></div>
<div class="x2"></div>本回答被提问者采纳
第2个回答  2011-03-09
上面的div高度设为auto style=" height:auto;"
<div style=" border:solid 1px red; height:auto;"></div>
<div style=" border:solid 1px green;"></div>
相似回答