0

我正在使用精灵和 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*/
4

1 回答 1

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

​</p>

于 2012-11-21T20:12:55.157 回答