Page Widget How to - Create a Bounce ball








Question

We would like to know how to create a Bounce ball.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.ball {<!--from www  .  j a  va2s  .c  o m-->
  background: black;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  position: absolute;
  bottom: 0;
  left: 50%;
  -webkit-animation-name: bounceball;
  -webkit-animation-duration: 1s;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-direction: alternate;
  -webkit-animation-delay: 0;
  -webkit-animation-timing-function: ease-out;
  animation-name: bounceball;
  animation-duration: 1s;
  animation-iteration-count: infinite;
  animation-direction: alternate;
  animation-delay: 0;
  timing-function: ease-out;
  animation-play-state: running;
  animation-fill-mode: none;
}

@-webkit-keyframes bounceball {
 from { bottom:0;height: 90px;}
   10%{bottom: 0;height: 160px;}
 to {bottom: 50%;}
}
</style>
</head>
<body>
   <div class="ball"></div>
</body>
</html>

The code above is rendered as follows: