CSS弹跳动画在FF中不起作用

时间:2014-07-06 05:08:09

标签: css animation

我有一个简单的反弹动画通过webkit工作,任何想法为什么这个动画不能用于FF?

@-webkit-keyframes bounce { 
    0%, 20%, 50%, 80%, 100% {-webkit-transform: translateY(0);} 
    40% {-webkit-transform: translateY(-6px);}
    60% {-webkit-transform: translateY(-3px);}
} 

@keyframes bounce { 
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);} 
    40% {transform: translateY(-6px);}
    60% {transform: translateY(-3px);}
}

@-moz-keyframes bounce { 
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);} 
    40% {transform: translateY(-6px);}
    60% {transform: translateY(-3px);}
}

element {
    -webkit-animation: bounce 1.7s ease-in-out infinite;
    -moz-animation-name: bounce 1.7s ease-in-out;
    -ms-animation-name: bounce 1.7s ease-in-out;
    -o-animation-name: bounce 1.7s ease-in-out;
    animation-name: bounce 1.7s ease-in-out;
}

谢谢!

1 个答案:

答案 0 :(得分:0)

这是因为您为其他浏览器设置了animation-name而不是animation

div {
  -webkit-animation: bounce 1.7s ease-in-out infinite;
  -moz-animation: bounce 1.7s ease-in-out infinite;
  -ms-animation: bounce 1.7s ease-in-out infinite;
  -o-animation: bounce 1.7s ease-in-out infinite;
  animation: bounce 1.7s ease-in-out infinite;
}

Demo

请注意,如果您使用animation-name,则必须单独设置其他与动画相关的属性:

-moz-animation-name: bounce;
-moz-animation-duration:1.7s;
-moz-animation-timing-function: ease-in-out;
-moz-animation-iteration-count: infinite;