【发布时间】:2014-01-22 19:43:31
【问题描述】:
有谁知道我在哪里可以找到浏览器列表以及它们是否支持 CSS3 动画和关键帧?谢谢
【问题讨论】:
-
@BoltClock 添加为答案,我会接受。
有谁知道我在哪里可以找到浏览器列表以及它们是否支持 CSS3 动画和关键帧?谢谢
【问题讨论】:
Can I Use 是所有这类东西的地方,定期更新,而且总是准确的!
http://caniuse.com/css-animation
它们在这些日期实施:
Safari 4.0: 11/06/2008
Chrome 1.0: 02/09/2008
Firefox 5: 20/04/2011
IE 10: 09/2011
它们在 2009 年成为规范的一部分:http://www.w3.org/TR/css3-animations/
欲了解更多信息,请查看http://css3.bradshawenterprises.com/support/ 和http://css3.bradshawenterprises.com/animations/
【讨论】:
我要去this way。我不是在寻找浏览器,而是在寻找特征检测。这篇漂亮的文章将为我节省一些工作。所以,我在复制代码,你明白这一切意味着什么:-)。
/* Check if the Animation feature exists */
if(hasAnimation())
{
alert("Has!");
return;
}
function hasAnimation()
{
var elm = document.getElementById( 'imgDiv' )
animationstring = 'animation',
keyframeprefix = '',
domPrefixes = 'Webkit Moz O ms Khtml'.split(' '),
pfx = '';
if( elm.style.animationName === undefined )
{
var animation = false;
for( var i = 0; i < domPrefixes.length; i++ )
{
if( elm.style[ domPrefixes[i] + 'AnimationName' ] !== undefined )
{
pfx = domPrefixes[ i ];
animationstring = pfx + 'Animation';
keyframeprefix = '-' + pfx.toLowerCase() + '-';
animation = true;
break;
}
}
if( animation === false ) // animate in JavaScript fallback
return false;
}
/* Create animationstring */
elm.style[ animationstring ] = 'rotate 1s linear infinite';
var keyframes = '@' + keyframeprefix + 'keyframes rotate { '+
'from {' + keyframeprefix + 'transform:rotate( 0deg ) }'+
'to {' + keyframeprefix + 'transform:rotate( 360deg ) }'+
'}';
/* Add rule to stylesheet */
if( document.styleSheets && document.styleSheets.length )
{
document.styleSheets[0].insertRule( keyframes, 0 );
return true;
}
/* If there is no stylesheet, add rule to header */
var s = document.createElement( 'style' );
s.innerHTML = keyframes;
document.getElementsByTagName( 'head' )[ 0 ].appendChild( s );
return true;
}
更新:为了清楚起见,我重写了代码。 'elm' 元素也没有被定义。原演示代码is here.
【讨论】:
编辑:对于推荐 W3Schools 链接,我向大家道歉,我再也不会这样做了。
W3Schools 通常有这些类型的表格和信息,看看这个link。
目前看来,以下浏览器支持 CSS 动画:
还有,目前不支持的还有:
【讨论】: