Set animation to alternate between running forwards and backwards. - HTML CSS CSS

HTML CSS examples for CSS:Quiz

Description

Set animation to alternate between running forwards and backwards.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
div {<!--from   ww w . j a v a  2s .c  o m-->
    width: 100px;
    height: 100px;
    position: relative;
    background-color: red;
    animation-name: example;
    animation-duration: 4s;
    animation-iteration-count: infinite;
    animation-direction: alternate;
}

@keyframes example {
    0%   {background-color: red; left:0px; top:0px;}
    25%  {background-color: blue; left:0px; top:200px;}
    50%  {background-color: green; left:200px; top:200px;}
    75%  {background-color: yellow; left:200px; top:0px;}
    100% {background-color: red; left:0px; top:0px;}
}
</style>
</head>
<body>

<div></div>

</body>
</html>

Related Tutorials