Animation How to - Show image with fade in effect animation








Question

We would like to know how to show image with fade in effect animation.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
@-webkit-keyframes animate {<!--from   w ww  . j  a  v a  2s  .  c o m-->
   from { -webkit-transform:ease-in-out(0);opacity: 0;}
   to {-webkit-transform: ease-in-out(1);opacity: 1;}
}
#pseudo-background {
  top: 0px;
  left: 0px;
  z-index: -10;
  -webkit-animation-name: animate;
  -webkit-animation-duration: 3.333s;
  -webkit-animation-iteration-count: 1;
  -webkit-animation-timing-function: ease-in;
}
</style>
</head>
<body>
  <img src="http://www.java2s.com/style/download.png"
    id="pseudo-background" alt="foo" /> java2s.com
</body>
</html>

The code above is rendered as follows: