如何通過一個事件(hover,click..)觸發css3動畫的重新執行?在stackoverflow找到一個相關的問題,但是下面給出的答案也不起作用。http://jsfiddle.net/arunpjohny/8WQcy/1/這篇文章挺好的,介紹了重新運行css3動畫的不同方法animation必須是infinite,animation-play-state才有效。restart用這種方法挺好://retrievetheelementelement=document.getElementById("logo");//resetthetransitionby...element.addEventListener("click",function(e){e.preventDefault;//->removingtheclasselement.classList.remove("run-animation");//->triggeringreflow/*Theactualmagic*///withoutthisitwouldn'twork.Tryuncommentingthelineandthetransitionwon'tberetriggered.element.offsetWidth=element.offsetWidth;//->andre-addingtheclasselement.classList.add("run-animation");},false);
如何重新運行css3的動畫?
瀟瀟雨雨
2019-04-10 20:47:45
