CSS3 Animation无法在任何浏览器中运行

时间:2012-11-21 19:20:20

标签: css3 sprite css-animations

我正在使用精灵和CSS3动画来尝试进行翻转。它在CODA 2中有所作为,但是当我在Mozilla,Chrome,Safari和Opera中测试时,动画不会发生。

/*linkedin contact button*/
button{text-indent:-99999px; border: none; }
a.linkedin,a.linkedin:hover{display: block; cursor: pointer; background: url(../img/linked.png) no-repeat; width: 128px; height: 128px}
a.linkedin{background-position: -0 -0}
a.linkedin:hover{animation:first 1000s; -moz-animation:first 1000s; -webkit-animation:first 1000s; -o-animation:first 1000s;}

@keyframes first{from {background-position: -140px -0;} to {background-position: -0px -0;}}
@-moz-keyframes first{from {background-position: -140px -0;} to {background-position: -0 -0;}}
@-webkit-keyframes first{from {background-position: -140px -0;} to {background-position: -0 -0;}}
@-o-keyframes first{from {background-position: -140px -0;} to {background-position: -0 -0;}}
*a.linkedin:hover{background-position: -140px -0/9}/*for ie*/

1 个答案:

答案 0 :(得分:0)

为什么不使用CSS3过渡?如果您所做的只是改变背景位置,那么创建关键帧有点过头了。看到这个jsfiddle:

http://jsfiddle.net/RfbhD/3/

您需要的所有CSS:

a.linkedin {
    background: url(http://placekitten.com/300/128) 0 0 no-repeat; 
    cursor: pointer;
    display: block;
    width: 128px; 
    height: 128px; 

    -webkit-transition: background-position 1s ease; 
       -moz-transition: background-position 1s ease; 
         -o-transition: background-position 1s ease; 
            transition: background-position 1s ease; 
}

a.linkedin:hover{
    background-position: -140px 0; 
}