Animation How to - Set original image for animate background image








Question

We would like to know how to set original image for animate background image.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#slideshow {<!--  w  w w.ja  v  a  2 s  .  c o m-->
  position: relative;
  overflow: hidden;
  height: 100px;
}

#fixme {
  height: 60px;
  position: relative;
  overflow: hidden;
}

#animate-area {
  height: 100%;
  width: 2538px;
  position: absolute;
  left: 0;
  top: -15px;
  background-image: url('http://www.java2s.com/style/download.png');
  -ms-animation: animatedBackground 40s linear infinite;
  -moz-animation: animatedBackground 40s linear infinite;
  -webkit-animation: animatedBackground 30s linear infinite;
}
/* Put your css in here */
@keyframes animatedBackground {
  from { left:0;}
  to {left: -1269px;}
}
@-webkit-keyframes animatedBackground {
  from { left:0;}
  to {left: -1269px;}
}
@-moz-keyframes animatedBackground {
  from { left:0;}
  to {left: -1269px;}
}
</style>
</head>
<body>
  <div id="slideshow">
    <div id="fixme">
      <div id='animate-area'></div>
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: