CSS3 Animation + @keyframe run till the end

笑着哭i 提交于 2020-01-16 02:33:07

问题


I can't find the way to play an animation till the end when an element is :hover.

  • When i :hover out, the animation reset - but i want it to continue till the end.
  • JsFiddle
<div class="picture"></div>
    .picture:hover {
       -webkit-animation:swing 1s ease-in-out;
    }


    @-webkit-keyframes swing {
      [...] 
    }

回答1:


Probably not a complete solution, but add the following to your picture class:

-webkit-animation:swing 3600ms ease-in-out 6000s;
-webkit-transform-origin:top;

JsFiddle: http://jsfiddle.net/5SueS/4/




回答2:


I did like this http://jsfiddle.net/Z5aq7/

Instead of Hovering, I just made it a class (.animate) and adding the class on hover

$('.picture').hover(function(){
    $(this).addClass('animate');
});

Hope this helps!




回答3:


Seems that there is no pure css solutions, so best solution with JS:

Stackoverflow - animation on hover force entire animation



来源:https://stackoverflow.com/questions/16765727/css3-animation-keyframe-run-till-the-end

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