开发者

Detecting if a CSS3 property is doable using Jquery?

I'm wondering if I can figure out if a CSS3 property is doable in user's web browser

like:

if($('#element').css('-moz-transform', 'rotateX(180deg')){ //Do something }

Above example does not work. If it 开发者_如何学Pythonis not possible how do I detect the browser using javascript? For example, webkit browser like Chrome and Safari or Mozilla browser?


It's not JQuery, but my suggestion would be to use the Modernizr Javascript library.

It does exactly what you're asking, being able to detect support for a wide range of browser features which may or may not be available in various browsers, including CSS 2D transforms.

It adds a range of classes to your <body> element so you can set CSS styles according to feature support, and it also makes available a Javascript object with all the feature support flags, which you can query at any point.


It might be possible using getComputedStyle but it's far easier to use a plugin that unifies all the browser differences in CSS3. One good plugin is the jQuery transform plugin

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜