<div class="container">
<p>
The animation iterates infinitely, and the animation-direction is set to its default value <code>normal</code>.
</p>
<div class="element element-1"></div>
<hr>
<p>
The animation iterates infinitely, and the animation-direction is set to <code>alternate</code>.
</p>
<div class="element element-2"></div>
<hr>
<p>
The animation iterates infinitely, and the animation-direction is set to <code>reverse</code>.
</p>
<div class="element element-3"></div>
<hr>
<p>
The animation iterates infinitely, and the animation-direction is set to <code>alternate-reverse</code>.
</p>
<div class="element element-4"></div>
</div>
body {
background-color: #F5F5F5;
color: #555;
font-size: 1.1em;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
hr {
margin: 50px 0;
}
.container {
margin: 50px auto;
max-width: 700px;
padding: 30px;
border: 1px solid #aaa;
background-color: white;
}
.element {
width: 30px;
height: 30px;
border-radius: 50%;
position: relative;
top: 0;
left: 0;
-webkit-animation-name: zigzag;
animation-name: zigzag;
-webkit-animation-duration: 3s;
animation-duration: 3s;
-webkit-animation-timing-function: linear;
animation-timing-function: linear;
}
.element-1 {
background-color: #009966;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-direction: normal;
animation-direction: normal;
}
.element-2 {
background-color: purple;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-direction: alternate;
animation-direction: alternate;
}
.element-3 {
background-color: orange;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-direction: reverse;
animation-direction: reverse;
}
.element-4 {
background-color: #0099CC;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-direction: alternate-reverse;
animation-direction: alternate-reverse;
}
@-webkit-keyframes zigzag {
from {
left: 0;
top: 0;
}
15% {
left: 50px;
top: -50px;
}
30% {
left: 100px;
top: 0;
}
45% {
left: 150px;
top: -50px;
}
60% {
left: 200px;
top: 0;
}
75% {
left: 250px;
top: -50px;
}
100% {
left: 300px;
top: 0;
}
}
@keyframes zigzag {
from {
left: 0;
top: 0;
}
15% {
left: 50px;
top: -50px;
}
30% {
left: 100px;
top: 0;
}
45% {
left: 150px;
top: -50px;
}
60% {
left: 200px;
top: 0;
}
75% {
left: 250px;
top: -50px;
}
100% {
left: 300px;
top: 0;
}
}