Animation How to - Create loading Spin animation








Question

We would like to know how to create loading Spin animation.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.loading {<!--from  w  ww  . j  a  v  a  2 s . c  o m-->
  position: absolute;
  top: 50px;
  left: 50px;
  background-color: rgba(0, 0, 0, 0);
  border: 7px solid rgba(125, 125, 125, 0.8);
  opacity: .9;
  border-top: 7px solid rgba(0, 0, 0, 0);
  border-left: 7px solid rgba(0, 0, 0, 0);
  border-radius: 50px;
  box-shadow: 0 0 35px #ccc;
  width: 50px;
  height: 50px;
  -webkit-animation: spin 1.2s infinite linear;
  z-index: -9;
}

@-webkit-keyframes spin { 
0% {-webkit-transform: rotate(0deg);}
100%{-webkit-transform:rotate(360deg)}
}
</style>
</head>
<body>
  <div class="loading"></div>
</body>
</html>

The code above is rendered as follows: