开发者

Are there some good CSS practices in order to avoid browser-compatibility issues with IE?

I'开发者_JS百科ve discover so far that:

  • stating the width in some elements fix issues in IE.

  • and of course using a CSS reset

Do you know any others?


  • Learn about hasLayout

  • Inline block behavior can be achieved on IE7 by turning on hasLayout, then setting display to inline. This has turned out to be quite useful to me.

  • Make sure your doctype is present and correct. This alone can save hours of pain.

  • Use conditional comments anytime you need to hack something especially for IE. PLEASE don't fall into the amateur's habit of adding star/underscore junk in your main stylesheet.


I'd say that manually setting width would more often than not break things in IE, as a lot of IE versions implement a flawed box model.

I'd also say that a lot of all browser incompatibilities originate from a sub par understanding of the box model and float/clear, block/inline.

Having said that, I of course do not deny that it is IE, rather than the developer, that is the real problem, but I usually seek to avoid browser incompatibilities by using HTML structures that not even IE could miss-interpret, rather than through CSS hacks, and I've found that that is often quite doable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜