How can I let my css3 animation to stay at its animated position when it finishes animating? [duplicate]

最后都变了- 提交于 2019-12-08 02:53:45

问题


Possible Duplicate:
Webkit CSS Animation issue - persisting the end state of the animation?

I want to keep the position of my animated div when it finishes running. Right now I animating the div on mouse hover, but the div return back to it's position even if I'm still hovering over it.

Is there a way to let it get back only when I mouse out?

http://jsfiddle.net/neoswf/X5a64/

div{
    width:100px;height:100px;margin:1em;background:red
}
div:hover {
  -webkit-animation-name: rotateThis;
  -webkit-animation-duration:1s;
  -webkit-animation-iteration-count: 1;
  -webkit-animation-timing-function:ease-in-out;
  -webkit-transform: translateZ(0);
}
@-webkit-keyframes rotateThis {
  from { -webkit-transform:scale(1) rotate(0deg); }
  to { -webkit-transform:scale(1.1) rotate(100deg); }
}​

回答1:


You're looking for

-webkit-animation-fill-mode: forwards;

DEMO




回答2:


Use animation-fill-mode: forwards to persist the end state:

-webkit-animation-fill-mode: forwards;

http://jsfiddle.net/stjHZ/



来源:https://stackoverflow.com/questions/13981730/how-can-i-let-my-css3-animation-to-stay-at-its-animated-position-when-it-finishe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!