浏览器兼容性问题-IE6双倍边距

来源:互联网 发布:电话网络怎么网上缴费 编辑:程序博客网 时间:2024/06/15 14:29

IE6双倍边距就是指当元素有float属性,又有margin属性时,在IE6下面显示的margin的值是设置值的两倍

<div style="width:200px;height:50px;background:#ccc;"> <div style="width:100px; height:50px;float:left;margin-left:10px; background:#eee;"></div> </div>

ie6下显示:

ie8及以上显示:

可以看出左边距在IE6下面明显比IE8下面的大,在ie6下面的左边距变成了20px,而不是设置的10px。

解决办法:

IE6双倍边距一招搞定:将有float属性的元素添加display:inline属性

<div style="width:200px;height:50px;background:#ccc;"> <div style="width:100px; height:50px;float:left;margin-left:10px; background:#eee; display:inline"></div> </div> 


0 0