Animation How to - Animate keyframe on color Animation








Question

We would like to know how to animate keyframe on color Animation.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.circle {<!--from  w  w w . j av a  2  s  .  co m-->
  width: 200px;
  height: 200px;
  background: #FF0000;
  position: relative;
  -webkit-animation: crazyfromtop 1s ease-out;
  border-radius: 200px
}

@-webkit-keyframes crazyfromtop { 
    0%{background-color: #FF0000;top: -300px}
    20%{background-color:#FF8429;}
    40%{background-color:#FFFF10;}
    60%{background-color:#D6EF39;}
    80%{background-color:#00FFFF;}
    100%{background-color:#FF0080;}
}
</style>
</head>
<body>
  <div class="circle"></div>
</body>
</html>

The code above is rendered as follows: