Animation How to - Rotate CSS Animation








Question

We would like to know how to rotate CSS Animation.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#anim {<!-- w  ww . j  a  v  a2s  .  c o m-->
  width: 490px;
  position: relative;
}

#rays {
  width: 490px;
  height: 490px;
  background: url(http://placehold.it/60x60) no-repeat;
}

#smiley {
  width: 128px;
  height: 128px;
  background:
    url(http://placehold.it/60x60);
  position: absolute;
  top: 181px;
  left: 181px;
}

@-webkit-keyframes rays {
    from { -webkit-transform:rotate(0deg);}
    to {-webkit-transform: rotate(360deg);}
}
.animated {
  -webkit-transform-origin: center center;
  -webkit-animation: rays 60s infinite linear;
}
</style>
</head>
<body>
  <div id="anim" class="animated">
    <div id="rays"></div>
    <div id="smiley"></div>
  </div>
</body>
</html>

The code above is rendered as follows: