We would like to know how to change background color with key frame.
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!--from w w w. ja va2s. c o m-->
width: 100px;
height: 100px;
background: red;
position: relative;
-webkit-animation: play 5s step-end;
animation: play 5s step-end;
}
@-webkit-keyframes play {
0% {background: red;}
25%{background:green;}
45%{background:blue;}
55%{background:orange;}
75%{background:black;}
100%{background:white;}
}
@-keyframes play {
0% {background: red;}
25%{background:green;}
45%{background:blue;}
55%{background:orange;}
75%{background:black;}
100%{background:white;}
}
</style>
</head>
<body>
<div></div
</body>
</html>
The code above is rendered as follows: