HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> div{ width: 100px; height: 100px; line-height: 6; text-align: center; border: 1px solid #000; background: #39ac39; margin-bottom: 20px; } @-webkit-keyframes myAnimation { from {border-radius: 0%; background: #f69d3c;} to {border-radius: 50%; background: #0066ff} } @keyframes myAnimation { from {border-radius: 0%; background: #f69d3c;} to {border-radius: 50%; background: #0066ff} } </style> </head> <body> <h1>CSS animation-fill-mode Property</h1> <div> Div </div> <button onclick="myFunction()">Click Me</button> <script> var x = document.getElementsByTagName("div")[0]; function myFunction(){ x.style.animation = "myAnimation 1s 1"; x.style.WebkitAnimation = "myAnimation 1s 1"; x.style.animationDelay = "1s"; x.style.WebkitAnimationDelay = "1s"; x.style.animationFillMode = "both"; x.style.WebkitAnimationFillMode = "both"; } </script> <p><strong>Note</strong>: Click on the button change the 'animation-fill-mode' from none to both.</p> </body> </html>
OUTPUT
×

Save as Private