Edit This Code:
<!DOCTYPE html>
<html>
<head>
<style>
div {
    width: 100px;
    height: 100px;
    background-color: red;
    -webkit-animation-name: example; /* Chrome, Safari, Opera */
    -webkit-animation-duration: 4s; /* Chrome, Safari, Opera */
    animation-name: example;
    animation-duration: 4s;
}


/* Chrome, Safari, Opera */
@-webkit-keyframes example {
    from {background-color: red;}

    to {background-color: yellow;}
}

/* Standard syntax */
@keyframes example {
    from {background-color: red;}

    to {background-color: yellow;}
}
</style>
</head>
<body>

<p><b>Note:</b> This example does not work in Internet Explorer 9 and earlier versions.</p>

<div></div>

<p><b>Note:</b> When an animation is finished, it changes back to its original style.</p>

</body>
</html>


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