css 动画效果

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};
}

posted @ 2015-05-14 22:48  谢小锋  阅读(704)  评论(0)    收藏  举报