开发者

CSS2 selectors and IE

I'd like to use CSS2 selectors ( parent > child, element:first-child, etc) in my stylesheet but IE6 doesn't seem to recognize t开发者_StackOverflow社区hose. Is there any plugin (jQuery preferably) that would allow me to use pseudo-selectors freely without worrying about the damned IE6?


UPDATED:

The Super Selectors jQuery plugin scans the page's styles for selectors which aren't supported by all browsers and then adds apropriate classes to elements that those CSS3 selectors are targeting.

You can also look at this CSS3 selectors for IE5/IE8 called ie-css3.js


I'd recommend against using javascript to fix those kind of problems.

The best approach I've found is using conditional comments and create a IE only CSS file, optimized for that hellish browser.

In the long run, the small duplication of work is compensated by the smaller amount of incompatibilities that you'd have to correct between sane browsers and IE.


As a rule, I go with adding classNames to the body tag via conditional comments as my preferred method to deal with cross-browser difficulties.

However, if that's out and if performance is not a concern, you can always give Dean Edwards's excellent IE7.js a try. It will parse and grok your stylesheet, picking out and implementing those unsupported selectors.

Beware that, as your stylesheets increase and size and complexity, the script's (and your site's) performance will suffer in IE6. However, in a lot of cases things should run just fine. Make sure to conditionally comment it in for IE6 and below and you'll be set.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜