运行 ❯
获取您自己的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往Spaces
<!DOCTYPE html> <html> <style> #myDIV { width: 100%; height: 50px; padding: 16px; background: orange; position: relative; font-size: 20px; text-align: center; animation: mymove 5s infinite; } @keyframes mymove { from {top: 0px;} to {top: 200px;} } </style> <body> <h1>Animation Events</h1> <h2>The animationName Property</h2> <p>This example uses the addEventListener() method to attach an "animationstart" event to a DIV element.</p> <p>The animationName property returns the animation name used in this animation:</p> <div id="myDIV"></div> <script> const div = document.getElementById("myDIV"); div.addEventListener("animationstart", myStartFunction); function myStartFunction(event) { this.innerHTML = "The animation-name is: " + event.animationName; } </script> </body> </html>