css3的动画需要遵循@keyframes规制
        <div>动画效果</div>
div{
    width: 100px;
    height: 100px;
    background: red;
/*    相对布局*/
    position: relative;
    animation: anim 5s infinite alternate;
    -webkit-animation: anim 5s infinite alternate;
    
}
@keyframes anim{
    
    0%{background: red;left: 0px;top: 0px}
    25%{background: blue;left: 200px;top: 0px}
    50%{background: orange;left: 200px;top: 200px}
    75%{background: yellow; left: 0px;top: 200px}
    100%{background: red;left: 0;top: 0px}
}
@-webkit-keyframes anim{
     0%{background: red;left: 0px;top: 0px}
    25%{background: blue;left: 200px;top: 0px}
    50%{background: orange;left: 200px;top: 200px}
    75%{background: yellow; left: 0px;top: 200px}
    100%{background: red;left: 0;top: 0px};
}
原文:http://www.cnblogs.com/xiezefeng/p/4504715.html