简体   繁体   English

使用Jquery检测CSS3属性是否可行?

[英]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 我想知道是否可以在用户的​​网络浏览器中使用CSS3属性

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? 如果不可能,如何使用javascript检测浏览器? For example, webkit browser like Chrome and Safari or Mozilla browser? 例如,Chrome和Safari等Webkit浏览器或Mozilla浏览器?

It's not JQuery, but my suggestion would be to use the Modernizr Javascript library. 它不是JQuery,但我的建议是使用Modernizr Javascript库。

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. 它完全能够满足您的要求,能够检测到对各种浏览器功能的支持,这些功能可能在各种浏览器中提供,也可能无法提供,包括CSS 2D转换。

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. 它将一系列类添加到<body>元素中,以便您可以根据功能支持设置CSS样式,并且还可以使用带有所有功能支持标志的Javascript对象,您可以随时查询该标志。

It might be possible using getComputedStyle but it's far easier to use a plugin that unifies all the browser differences in CSS3. 使用getComputedStyle可能是可行的,但使用统一CSS3中所有浏览器差异的插件要容易得多。 One good plugin is the jQuery transform plugin 一个不错的插件是jQuery transform插件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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