开发者

What's the best CSS property for detecting browser support for selectors

开发者 https://www.devze.com 2023-02-27 05:19 出处:网络
I\'m writing some Modernizr ext开发者_运维知识库ensions to detect browser support for things such as :first-child, :last-child in CSS. In order to do so I\'m applying a style and then checking to see

I'm writing some Modernizr ext开发者_运维知识库ensions to detect browser support for things such as :first-child, :last-child in CSS. In order to do so I'm applying a style and then checking to see if teh element has that style.

What's the most-reliable CSS property to use as my test style?

e.g. color is a bad choice as if you enter in #123abc the browser may convert it to rgb(#,#,#)

So I'm looking for a property that

  • Is supported across browsers
  • Won't be mutated to a different format by the browser

At the moment I'm using width, which is probably OK, but thought I'd check here anyway.


I just wrote this http://jsfiddle.net/laustdeleuran/3rEVe/ yesterday, which does exactly what you're talking about - it feature detects support for the :last-child pseudo selector. I'm also using width as my style to check on, and it seems to be working just fine.

I've so far tested it with succes in IE6-8 on Windows XP; IE9, Chrome 12, Safari 5, FireFox 4 and Opera 11 on Windows 7 and Opera 11, FireFox 4, Safari 5 and Chrome 12 on Mac.

Feel free to use it as it if you want to.

0

精彩评论

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