<div class="container">
<p>
Hover over this container to see the elements animate after different delays.
</p>
<p>
<code>animation-delay: 0s;</code>
</p>
<div class="element element-1"></div>
<hr>
<p>
<code>animation-delay: 1s;</code>
</p>
<div class="element element-2"></div>
<hr>
<p>
<code>animation-delay: 2s;</code>
</p>
<div class="element element-3"></div>
<hr>
<p>
<code>animation-delay: 4s;</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;
width: 90%;
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;
}
.container:hover .element {
-webkit-animation-name: zigzag;
animation-name: zigzag;
-webkit-animation-duration: 3s;
animation-duration: 3s;
-webkit-animation-iteration-count: 2;
animation-iteration-count: 2;
-webkit-animation-direction: alternate;
animation-direction: alternate;
-webkit-animation-timing-function: linear;
animation-timing-function: linear;
}
.element-1 {
background-color: #009966;
-webkit-animation-delay: 0s;
animation-delay: 0s;
}
.element-2 {
background-color: purple;
-webkit-animation-delay: 1s;
animation-delay: 1s;
}
.element-3 {
background-color: orange;
-webkit-animation-delay: 2s;
animation-delay: 2s;
}
.element-4 {
background-color: #0099CC;
-webkit-animation-delay: 3s;
animation-delay: 3s;
}
@-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;
}
}