Animation How to - Create Animated banner








Question

We would like to know how to create Animated banner.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-git.js'></script>
<style type='text/css'>
div {<!--  ww w . ja va 2 s . c  o m-->
  height: 130px;
  background-image:url(http://www.java2s.com/style/download.png);
  background-position: 0px 0px;
  background-repeat: repeat-x;
  animation: animatedBackground 40s linear infinite;
  -ms-animation: animatedBackground 40s linear infinite;
  -moz-animation: animatedBackground 40s linear infinite;
  -webkit-animation: animatedBackground 40s linear infinite;
}

@keyframes animatedBackground {
  from { background-position:00;}
  to {background-position: 100% 0;}
}
@-webkit-keyframes animatedBackground {
  from { background-position:00;}
  to {background-position: 100% 0;}
}
@-ms-keyframes animatedBackground {
  from { background-position:00;}
  to {background-position: 100% 0;}
}
@-moz-keyframes animatedBackground {
  from { background-position:00;}
  to {background-position: 100% 0;}
}
</style>
</head>
<body>
  <div class="wrap">
    <div></div>
  </div>
</body>
</html>

The code above is rendered as follows: