IE8 float issue with CSS

你。 提交于 2019-12-22 10:04:03

问题


I'm sure this must have been covered before because I'm sure I'm not the first to do this, but I can't find the answer. I am creating a shadow effect for a <div> using repeated background images. In the bottom two corners I use small 9x5 px images. I float them left and right and in Firefox and Safari they look perfect. In IE8 (and possibly other IEs) they float too far to the left and right about about 3px.

You can see the issue at here. It's an ebay template for my wife.

Thus far I've tried setting display:inline which was a fix for a similar IE6 issues. I also tried setting image margins and padding to 0px with no luck.

Any ideas?

Thanks, Carraig


回答1:


Whilst browsing your page I found that it is defaulting into quirks mode, which is the probable issue, because if I force it into Strict it seems to fix your floating problem in all cases of IE.

have a read of ppk's article here: http://www.quirksmode.org/css/quirksmode.html

he explains why its happening and how to fix it :)

Hope it helps!




回答2:


I think it has something to do with the float elements getting outside the borders of the div, try inserting this before you close the parent div:

<div style="clear: both; font-size: 1px; line-height: 0px;"> &nbsp;</div>


来源:https://stackoverflow.com/questions/1404547/ie8-float-issue-with-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!