Animation How to - Create Animation starts at different time








Question

We would like to know how to create Animation starts at different time.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.8.3.js'></script>
<style type='text/css'>
.a {<!--from   w w  w  .jav  a  2s  .c o  m-->
  animation-delay: 1s;
  animation: fade 1s forwards;
}
.b {
  animation-delay: 2s;
  animation: fade 2s forwards;
}
.c {
  animation-delay: 3s;
  animation: fade 3s forwards;
}
.d {
  width: 15px;
  height: 15px;
  background: #dbdbdb;
  border-radius: 50px;
  display: inline-block;
}

@keyframes fade { 
  0% {opacity: 0;}
  50%{opacity: 1;}
  100%{opacity:0;}
}
</style>
</head>
<body>
  <div class="a d"></div>
  <div class="b d"></div>
  <div class="c d"></div>
  <div class="a d"></div>
  <div class="b d"></div>
  <div class="c d"></div>
  <div class="a d"></div>
  <div class="b d"></div>
  <div class="c d"></div>
</body>
</html>

The code above is rendered as follows: