Animation How to - Compare keyframe animation timing functions








Question

We would like to know how to compare keyframe animation timing functions.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
@-webkit-keyframes width {
    0%, 100% {<!--from w  ww.ja va  2s.  c om-->
        width: 160px;
    }
    50% {
        width: 400px;
    }
}
@-moz-keyframes width {
    0%, 100% {
        width: 160px;
    }
    50% {
        width: 400px;
    }
}
@-o-keyframes width {
    0%, 100% {
        width: 160px;
    }
    50% {
        width: 400px;
    }
}
div {
    width:460px;
    height:40px;
    padding-left: 20px;
    margin: 10px 0;
    color:black;
    background:#EEE;
    -webkit-animation: width 5s infinite;
       -moz-animation: width 5s infinite;
         -o-animation: width 5s infinite;
}
#div1 {animation-timing-function: linear;}
#div2 {animation-timing-function: ease;}
#div3 {animation-timing-function: ease-in;}
#div4 {animation-timing-function: ease-out;}
#div5 {animation-timing-function: ease-in-out;}
/* Firefox 4: */
#div1 {-moz-animation-timing-function: linear;}
#div2 {-moz-animation-timing-function: ease;}
#div3 {-moz-animation-timing-function: ease-in;}
#div4 {-moz-animation-timing-function: ease-out;}
#div5 {-moz-animation-timing-function: ease-in-out;}
/* Safari and Chrome: */
#div1 {-webkit-animation-timing-function: linear;}
#div2 {-webkit-animation-timing-function: ease;}
#div3 {-webkit-animation-timing-function: ease-in;}
#div4 {-webkit-animation-timing-function: ease-out;}
#div5 {-webkit-animation-timing-function: ease-in-out;}
/* Opera: */
#div1 {-o-transition-animation-function: linear;}
#div2 {-o-transition-animation-function: ease;}
#div3 {-o-transition-animation-function: ease-in;}
#div4 {-o-transition-animation-function: ease-out;}
#div5 {-o-transition-animation-function: ease-in-out;}
  </style>
</head>
<body>
  <div id="div1">linear</div>
<div id="div2">ease</div>
<div id="div3">ease-in</div>
<div id="div4">ease-out</div>
<div id="div5">ease-in-out</div>
</body>
</html>

The code above is rendered as follows: