如何解决css浮动边距加倍错误?

发布时间:2019-09-04编辑:脚本学堂
如果某条边与浮动方向同向,则向该边上的浮动框应用边距时,边距会增加一倍。本文就举一实例来说明解决css浮动边距加倍的方法,需要的朋友学习一下。

 影响: Internet Explorer 6.0

该错误只影响ie而不影响其他浏览器,我们可以考虑用hack来解决!!!
_display:inline;
加入上面这句adobe官方解决方法:
Problem
When a margin is applied to a floated box on the same side as the direction the box is floated AND the floated box is the first one inside its
containing box, the margin is doubled. (In other words, a left-floated box with margin-left set to move it away from its containing box will be
twice as far away from the left edge of the containing box as intended.)

Solution
Specify display: inline; for the affected float.

Detailed description
This bug only reproduces when the floated element''s margin extends in the same direction as the float itself, and is between the float and the
container box''s inside edge. Subsequent floats with similar margins won''t reproduce this bug- just the first float in any row of floated
elements.