Animation How to - Animate background to create cloud








Question

We would like to know how to animate background to create cloud.

Answer


<!DOCTYPE html>
<html>
<head>
  <style type='text/css'>
#awan {<!--from  ww w .  ja va2  s .c  o m-->
  background: url(https://abs.twimg.com/images/themes/theme1/bg.png) center top repeat-x;
  height: 135px;
  animation: awan-animasi 10s linear infinite;
  -ms-animation: awan-animasi 10s linear infinite;
  -moz-animation: awan-animasi 10s linear infinite;
  -webkit-animation: awan-animasi 10s linear infinite;
}
@keyframes awan-animasi {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 100% 0;
  };
}
@-webkit-keyframes awan-animasi {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 100% 0;
  };
}
@-ms-keyframes awan-animasi {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 100% 0;
  };
}
@-moz-keyframes awan-animasi {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 100% 0;
  };
}
  </style>

</head>
<body>
  <div id="awan">
</div>
</body>
</html>

The code above is rendered as follows: