IE8的margin-top兼容问题
作者:freethy 发布于:2011-12-8 12:28 Thursday
今天调试CSS,在IE8下出现了一个margin-top的bug,查了下,在网上找到了如下解决方案:
问题:
父div在没边框的情况下,子div如果设了 margin-top, 子div的margin无效,父div有了子div的margin-top属性.假设设了边框就没问题.
例子:
<div style=”width:400px; height:30px; background:#CCCCCC; border:1px solid #999999″>
<div style=”margin-top:5px; width:55px; height:25px; background:#003399″></div>
</div>
<div style=”width:333px; height:40px; background-color:#000000″>
<div style=”width:33px; height:20px; margin-top:5px; background:#CCCCCC”></div>
</div>
解决方法:
给父DIV设个:overflow:hidden;
from:http://www.cnblogs.com/inaugust/archive/2011/05/09/2041061.html