简体   繁体   English

CSS3动画支持吗?

[英]CSS3 Animations support?

Anybody know where I can find a table of browsers and whether or not they support CSS3 animations and keyframes? 有人知道我在哪里可以找到浏览器的表格,以及它们是否支持CSS3动画和关键帧? Thanks 谢谢

Can I Use is the place for all of this sort of thing, regularly updated, and always accurate! 我可以使用它来存放所有此类事物,并定期进行更新并且始终准确!

http://caniuse.com/css-animation http://caniuse.com/css-animation

They were implemented on these dates: 它们在以下日期实施:

Safari 4.0: 11/06/2008
Chrome 1.0: 02/09/2008
Firefox 5: 20/04/2011
IE 10: 09/2011

They became part of the spec in 2009: http://www.w3.org/TR/css3-animations/ 它们在2009年成为规范的一部分: http//www.w3.org/TR/css3-animations/

For more info, checkout http://css3.bradshawenterprises.com/support/ and http://css3.bradshawenterprises.com/animations/ 有关更多信息,请访问http://css3.bradshawenterprises.com/support/http://css3.bradshawenterprises.com/animations/

I'm going this way . 我要这样走 Instead of looking for the browser, I'm looking at feature detection. 我正在寻找功能检测,而不是寻找浏览器。 This nifty write-up will save me some work. 这个漂亮的文章将为我节省一些工作。 So, I'm copying the code, you figure out what it all means :-). 所以,我在复制代码,您知道这意味着什么:-)。

/* 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;
}

Update: I've rewritten the code for clarity. 更新:为了清楚起见,我重写了代码。 Also the 'elm' element wasn't defined. 同样也没有定义'elm'元素。 The original demo code is here . 原始的演示代码在这里

EDIT: I apologize to everyone for recommending a W3Schools link, I will NEVER do it again. 编辑:我向每个人推荐W3Schools链接表示歉意,我再也不会做。


W3Schools usually has these types of table and information, check out this link . W3Schools通常具有这些类型的表和信息,请查看此链接

It looks like as of now, the following browsers support CSS animations: 截至目前,以下浏览器支持CSS动画:

  • Firefox 火狐
  • Chrome
  • Safari 苹果浏览器

And, the ones left, which don't currently support it are: 而且,目前尚不支持它的是:

  • IE IE
  • Opera 歌剧

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

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