Edit This Code:
<!DOCTYPE html>
<html>
<head>
<style>
div {
    width: 100px;
    height: 100px;
    background: red;
    position: relative;
    -webkit-animation: mymove 2s infinite;  /* Chrome, Safari, Opera */
    animation: mymove 2s infinite;
}


/* Chrome, Safari, Opera */
@-webkit-keyframes mymove {
    from {left: 0px;}

    to {left: 200px;}
}

@keyframes mymove {
    from {left: 0px;}

    to {left: 200px;}
}

/* Chrome, Safari, Opera */
@-webkit-keyframes myNEWmove {
    from {width: 0px;}

    to {width: 500px; background: blue;}
}

@keyframes myNEWmove {
    from {width: 0px;}

    to {width: 500px; background: blue;}
}
</style>
</head>
<body>

<p>Click the "Try it" button to change what keyframes to use in the animation:</p>
<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
    document.getElementById("myDIV").style.WebkitAnimationName = "myNEWmove"; // Code for Chrome, Safari, and Opera
    document.getElementById("myDIV").style.animationName = "myNEWmove";
}
</script>

<p><strong>Note:</strong> The animationName property is not supported in Internet Explorer 9 and earlier versions.</p>
<div id="myDIV"></div>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy