简体   繁体   English

CSS动画恢复为原始状态

[英]CSS animation reverts to original state

  document.getElementById("clicky").addEventListener("click", changeMe); function changeMe() { var ele = document.getElementById("item"); ele.className= "hide"; } 
 #clicky{cursor:pointer;} .hide { animation: fadeout 1s ; -webkit-animation: fadeout 1s ; /* Chrome, Safari, Opera */ -webkit-animation-fill-mode: forwards; } /* Chrome, Safari, Opera */ @-webkit-keyframes fadeout { from { display:block; visibility:visible; opacity: 1;} to { display:none; visibility:hidden; opacity:0;} } /* Standard syntax */ @keyframes fadeout { from { display:block; visibility:visible; opacity: 1;} to { display:none; visibility:hidden; opacity:0;} } 
 <a id="clicky">Click me</a> <br /><br /> <div id="item">I should go bye byes!<br />But instead, I return!!!</div> 

I have seen the similar questions aready, such as css3 animation keep reverting to original state 我看到过类似的问题,例如css3动画不断恢复为原始状态

Most of them suggest adding -webkit-animation-fill-mode: forwards; 他们中的大多数建议添加-webkit-animation-fill-mode: forwards; which I have but it doesn't fix the issue because I'm trying to do this in IE 11. 我有,但不能解决问题,因为我正在尝试在IE 11中执行此操作。

Every time my animation runs, it reverts back to the original state. 每次我的动画运行时,它都会恢复为原始状态。

It works fine in Chrome, but I need this in IE 10+. 它在Chrome中运行良好,但在IE 10以上版本中需要。

Just add 只需添加

animation-fill-mode: forwards;

which is the standard syntax for the webkit prefixed version you are using. 这是您使用的Webkit前缀版本的标准语法。

http://jsfiddle.net/d2d46zf8/7/ http://jsfiddle.net/d2d46zf8/7/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM