Animation How to - Change image position during animation








Question

We would like to know how to change image position during animation.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#float {
  position: relative;
  -webkit-animation: floatBubble 2s infinite normal ease-out;
  animation: floatBubble 2s infinite normal ease-out;
}<!--from w w  w . j  a v a 2 s  . co m-->

@-webkit-keyframes floatBubble { 
  0% {top: 500px;}
  100%{top:0px;}
}
@keyframes floatBubble { 
   0% {top: 500px;}
   100%{top:0px;}
}
</style>
</head>
<body>
  <div id="float">
    <img
      src="http://www.java2s.com/style/download.png"
      height="100px" width="100px" alt="bubbles">
  </div>
</body>
</html>

The code above is rendered as follows: