Animation How to - Moving an image up the screen with KEYFRAMES








Question

We would like to know how to moving an image up the screen with KEYFRAMES.

Answer


<!DOCTYPE html>
<html>
<head>
</head><!--from w w  w .  j  a  v a2s  . co  m-->
<style>
#float {
  position: relative;
  -webkit-animation: floatBubble 2s infinite;
  -webkit-animation-direction: alternate;
  border-radius: 50%;
  margin-top: 10px;
}

@-webkit-keyframes floatBubble {
  from { top:0;-webkit-animation-timing-function: ease-in;}
  to {top: 200px;-webkit-animation-timing-function: ease-in;}
}
</style>
<body>
  <div id="float">
    <img id=float
      src="http://www.java2s.com/style/download.png"
      height="100px" width="100px" alt="bubbles">
  </div>
</body>
</html>

The code above is rendered as follows: