Animation How to - Create Spin animation








Question

We would like to know how to create Spin animation.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!--from   ww w .  jav a 2  s  . c  o  m-->
  background-color: black;
  width: 50px;
  height: 50px;
  disply: inline-block;
}

@-webkit-keyframes spin {
from { -webkit-transform:rotate(0deg);}
to {-webkit-transform: rotate(360deg);}
}

.playing {
  -webkit-animation-name: spin;
  -webkit-animation-duration: 1500ms;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-timing-function: linear;
}

.playing:hover {
  -webkit-animation-play-state: paused;
}
</style>
</head>
<body>
  <div class="playing"></div>
</body>
</html>

The code above is rendered as follows: