我正在尝试为我正在开发的摇滚剪刀游戏实现这个简单的动画:
http://jsfiddle.net/franciov/kbngz27s/1/
@keyframes arm-out {
from {
left: 0em;
}
to {
left: 5em;
}
}
.player > .arm.out {
animation-name: arm-out;
animation-duration: 0.5s;
animation-fill-mode: forwards;
}
基本上,我希望玩家:
点(3)的动画延迟效果很好:
@keyframes reveal {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.hand.reveal {
animation-name: reveal;
animation-delay: 0.5s;
animation-duration: 0.2s;
animation-fill-mode: forwards;
}
但是当我尝试为点(2)添加动画延迟属性时,事情就不再正常了,因为你可以尝试下一个JSFiddle:
http://jsfiddle.net/franciov/kbngz27s/2/
.player > .arm.out {
animation-name: arm-out;
animation-delay: 0.8s; /* This is not working properly */
animation-duration: 0.5s;
animation-fill-mode: forwards;
}
有什么想法吗?
我在Chrome 45.0.2454.101和Firefox 43.0a2上尝试了上面的JSFiddles。
答案 0 :(得分:0)
您只需将left: 0;
添加到.arm.out
,因为当您点击该按钮时,会删除in
课程,并且您已left: 5em;
你的arm
课程。
将“out arm”的左侧位置设置为零,然后让动画完成工作。
.player > .arm.out {
left: 0; /* Add this one. */
animation-name: arm-out;
animation-delay: 0.8s; /* This is working for me (Chrome 45) */
animation-duration: 0.5s;
animation-fill-mode: forwards;
}
小提琴: http://jsfiddle.net/kbngz27s/3/
(为.hand.reveal
添加了一些时间,因此它没有出现在手臂之前)。奇怪的是,它有时会因为你说而失败,但不是每次......