简体   繁体   中英

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 is 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM