We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
如果您提前知道需要嗅探哪些浏览器供应商前缀,则可以检测受支持的 CSS 属性。我已经为该机制编写了要点:
https://gist.github.com/1096784
cssSandpaper 是一个 JS 库,旨在解析CSS并动态实现polyfills以实现各种CSS3效果:
http://www.useragentman.com/blog/csssandpaper-a-css3-javascript-library/< /a>
还有一个 jQuery 库,它以相反的顺序运行,并在调用 $.animate() 时默默地实现可能的转换:
https://github.com/louisremi/jquery.transition.js
It is possible to detect supported CSS properties, provided you're aware in advance of what browser vendor prefixes you need to sniff for. I've written a gist for the mechanism:
https://gist.github.com/1096784
cssSandpaper is a JS library that aims to parse CSS and dynamically implement polyfills for various CSS3 effects:
http://www.useragentman.com/blog/csssandpaper-a-css3-javascript-library/
There is also a jQuery library that operates in reverse order, and silently implements transitions where possible when you call $.animate():
https://github.com/louisremi/jquery.transition.js
遗憾的是,大多数浏览器在渲染页面时都会删除任何不受支持的 CSS 声明,这意味着如果浏览器不支持给定的 CSS 功能,您将无法查看元素的
style
属性,并且查看该功能的样式表条目,即使它位于您的 CSS 文件中。IE 是个例外,这就是为什么像 CSS3Pie 这样的 polyfill 能够工作,但我不相信任何其他浏览器能让你看到它们已经删除的 CSS 声明,所以 Javascript 解决方案也需要重新 -将 CSS 文件本身作为纯文本加载,并在它开始实际实现该功能之前重新解析它。
这样做的含义是,您所要求的内容可能对浏览器来说太重,不值得付出努力(特别是因为我们正在谈论旧版本,无论如何它都比较慢)。
这个问题在一个问题上问了几乎同样的事情一年前。当时没有答案,我想现在也没有答案。
不过,答案中提到了一个 JQuery 插件,它可以满足您的需求,但相反(即您需要在所有浏览器中将其作为脚本运行,但它使用脚本中的 CSS 功能(如果可用))。我想这是你能得到的最接近的结果。
Sadly, most browsers drop any unsupported CSS declarations when they are rendering pages, meaning that if a browser doesn't support a given CSS feature, you won't be able to look at an element's
style
property and see that feature's stylesheet entry, even if it was in your CSS file.IE is the exception to this, which is why polyfills like CSS3Pie are able to work, but I don't believe any other browser gives you any visibility of CSS declarations which they've dropped, so a Javascript solution would also need to re-load the CSS file itself as plain text, and re-parse it, before it even began to actually implement the feature itself.
The implications of this are that what you're asking for would probably be too heavy on the browser to be worth the effort (particularly since we're talking about older versions, which are slower anyway).
This question on SO was asking pretty much the same thing, over a year ago. There wasn't an answer then, and I don't think there is still.
There was a JQuery plugin mentioned in an answer, though, which does what you want, but in reverse (ie you need to run it as a script in all browsers, but it uses the CSS feature within the script, if it's available). That's the closest you're going to get, I think.
尝试 eCSStender: http://ecsstender.org/extensions/css3-transitions/index.html< /a> 我们使用它来进行相对简单的显示/隐藏元素。
Try eCSStender: http://ecsstender.org/extensions/css3-transitions/index.html We used this for a relatively simple one to show/hide an element.
jQueryUI 的 addClass/removeClass 方法(不是常规方法!)可以为类的属性设置动画。
The addClass/removeClass methods of jQueryUI (not regular!) can animate the properties of a class.