CSS3 Loading Animation

by Terrance Smith

HTML

<div class="loadingdiv">
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
</div>

CSS

.loadingdiv span{
   display: inline-block;
    vertical-align: middle;
    width: 10px;
    height: 10px;
    margin: 50px auto;
    background: #174C4F;
    border-radius: 5px;
    -webkit-animation: loading 0.9s infinite alternate;
    -moz-animation: loading 0.9s infinite alternate;
    box-shadow:1px 1px 1px #444444;
}

.loadingdiv span:nth-of-type(2) {
    background: #207178;
    -webkit-animation-delay: 0.2s;
    -moz-animation-delay: 0.2s;
}
.loadingdiv span:nth-of-type(3) {
    background: #FF9666;
    -webkit-animation-delay: 0.4s;
    -moz-animation-delay: 0.4s;
}
.loadingdiv span:nth-of-type(4) {
    background: #FFE184;
    -webkit-animation-delay: 0.6s;
    -moz-animation-delay: 0.6s;
}
.loadingdiv span:nth-of-type(5) {
    background: #F5E9BE;
    -webkit-animation-delay: 0.8s;
    -moz-animation-delay: 0.8s;
}

@-webkit-keyframes loading {
  0% {
    width: 10px;
    height: 10px;
    -webkit-transform: translateZ(0);
  }
  100% {
    width: 24px;
    height: 24px;
    -webkit-transform: translateZ(-21px);
  }
}
@-moz-keyframes loading {
  0% {
    width: 10px;
    height: 10px;
    -moz-transform: translateZ(0);
  }
  100% {
    width: 24px;
    height: 24px;
    -moz-transform: translateZ(-21px);
  }
}