Firefox 关于DIV高度无法自适应的两种解决

如果设置了一个DIV的高度,当DIV里实际内容大于所设高度,ie会自动拉伸以适应DIV容器大小,ff会固定DIV的高度,超过部分超出DIV底线以外,出现和下面的内容重叠的现象。如果不给DIV设置高度,在Firefox中将不回因为里面的内容而撑开,而IE中就会自动根据内容撑开

解决方案:
1、在DIV内部的最后追加clear:both样式

<div style="background-color:#FF0000;">
    <div style="float:left; height:200px">Jmedia Design</div>
    <div style="float:right; height:800px">www.jmedia.cn</div>
    <div style="clear:both"></div>
</div>


2、对DIV使用overflow:auto;

<div style="overflow:auto;">
    <div style="float:left; background-color:#000000;height:200px">1111111111</div>
    <div style="float:right;background-color:#000000; height:300px"">2222222222</div>
</div>
posted on 2008-05-04 19:38  jecoso  阅读(717)  评论(0编辑  收藏  举报