Animation How to - Create Spinning Animation at different speed








Question

We would like to know how to create Spinning Animation at different speed.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
@-webkit-keyframes spinnerRotate {<!--  www  .  j a v  a2s  .  co m-->
  from {-webkit-transform: rotate(0deg);}
    to {-webkit-transform: rotate(360deg);}
}
@-moz-keyframes spinnerRotate {
  from {-moz-transform: rotate(0deg);}
    to {-moz-transform: rotate(360deg);}

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

}
#spin2 {
  position: fixed;
  top: 2%;
  left: 10%;
  -webkit-animation-name: spinnerRotate;
  -webkit-animation-duration: 5s;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-timing-function: linear;
  -moz-animation-name: spinnerRotate;
  -moz-animation-duration: 5s;
  -moz-animation-iteration-count: infinite;
  -moz-animation-timing-function: linear;
  -ms-animation-name: spinnerRotate;
  -ms-animation-duration: 5s;
  -ms-animation-iteration-count: infinite;
  -ms-animation-timing-function: linear;
}

@-webkit-keyframes spinnerRotate {
  from {-webkit-transform: rotate(0deg);}
    to {-webkit-transform: rotate(360deg);}
}
@-moz-keyframes spinnerRotate {
  from {-moz-transform: rotate(0deg);}
    to {-moz-transform: rotate(360deg);}
}
@-ms-keyframes spinnerRotate {
  from {-ms-transform: rotate(0deg);}
    to {-ms-transform: rotate(360deg);}
}
#spin {
  position: fixed;
  top: 2%;
  left: 0%;
  -webkit-animation-name: spinnerRotate;
  -webkit-animation-duration: 2s;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-timing-function: linear;
  -moz-animation-name: spinnerRotate;
  -moz-animation-duration: 2s;
  -moz-animation-iteration-count: infinite;
  -moz-animation-timing-function: linear;
  -ms-animation-name: spinnerRotate;
  -ms-animation-duration: 2s;
  -ms-animation-iteration-count: infinite;
  -ms-animation-timing-function: linear;
}
</style>
</head>
<body>
  <div id="spin">
    <img
      src="http://www.java2s.com/style/download.png" />
  </div>
  <div id="spin2">
    <img
      src="http://www.java2s.com/style/download.png" />
  </div>
</body>
</html>

The code above is rendered as follows: