css3 animation demo

animation

by Huy Tuấn

HTML

<div></div>

CSS

/* Cú pháp  */
@keyframes vidu {
    0%   {background-color:yellow; left:0px; top:0px;}
    25%  {background-color:red; left:100px; top:0px;}
    50%  {background-color:blue; left:100px; top:100px;}
    75%  {background-color:green; left:0px; top:100px;}
    100% {background-color:yellow; left:0px; top:0px;}
}
/* Chrome, Safari, Opera */
@-webkit-keyframes vidu {
    0%   {background-color:yellow; left:0px; top:0px;}
    25%  {background-color:red; left:100px; top:0px;}
    50%  {background-color:blue; left:100px; top:100px;}
    75%  {background-color:green; left:0px; top:100px;}
    100% {background-color:yellow; left:0px; top:0px;}
}
div {
    width: 50px;
    height: 50px;
    background-color: yellow;
    position: relative;
    /* Cú pháp chuẩn */
    animation-name: vidu;
    animation-duration: 3s;
    animation-timing-function: linear;
    animation-delay: 2s;
    animation-iteration-count: infinite;
    animation-direction: alternate;
    /* Chrome, Safari, Opera */
    -webkit-animation-name: vidu;
    -webkit-animation-duration: 3s;
    -webkit-animation-timing-function: linear;
    -webkit-animation-delay: 2s;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-direction: alternate;
}