Javascript 在 IE9+ 中使用 CSS3 动画
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9060223/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using CSS3 Animations in IE9+
提问by Mathew Hood
I have been trying to get these css3 animations to work in IE9 for a few hours today and I am stumped!
今天我一直试图让这些 css3 动画在 IE9 中工作几个小时,但我被难住了!
I tried implementing a few JavaScript fallbacks but my knowledge is very limited so they failed. I am unsure if it was failing due to my user errors or code errors.
我尝试实现一些 JavaScript 回退,但我的知识非常有限,所以他们失败了。我不确定它是否由于我的用户错误或代码错误而失败。
Here is a jsFiddle of my code so far, I have replaced the background images with colours. Basically the green and black squares rotate in Firefox and Webkit browsers.
到目前为止,这是我的代码的 jsFiddle,我已经用颜色替换了背景图像。基本上绿色和黑色方块在 Firefox 和 Webkit 浏览器中旋转。
I want to have it running on IE9 also.
我也想让它在 IE9 上运行。
If you can please help me with this I would be very grateful!
如果你能帮我解决这个问题,我将不胜感激!
回答by eivers88
I would use Modernizrto detect when css animations are not supported. With Modernizr, it's as simple as:
我会使用Modernizr来检测何时不支持 css 动画。使用 Modernizr,它很简单:
if(!Modernizr.cssanimations) {
//jQuery fallback
}
As for rotating with jQuery I would use: http://jqueryrotate.com/
至于使用 jQuery 旋转,我会使用:http: //jqueryrotate.com/