浏览器支持:css
Internet Explorer 十、Firefox 以及 Opera 支持 animation 属性。html
Safari 和 Chrome 支持替代的 -webkit-animation 属性。web
注释:Internet Explorer 9 以及更早的版本不支持 animation 属性。浏览器
示例:动画
<!DOCTYPE html> <html> <head> <style> div { width:100px; height:100px; background:red; position:relative; animation:mymove 5s infinite; -moz-animation:mymove 5s infinite; /* Firefox */ -webkit-animation:mymove 5s infinite; /* Safari and Chrome */ -o-animation:mymove 5s infinite; /* Opera */ } @keyframes mymove { from {top:0px;} to {top:200px;} } @-moz-keyframes mymove /* Firefox */ { from {top:0px;} to {top:200px;} } @-webkit-keyframes mymove /* Safari and Chrome */ { from {top:0px;} to {top:200px;} } @-o-keyframes mymove /* Opera */ { from {top:0px;} to {top:200px;} } </style> </head> <body> <p><b>注释:</b>本例在 Internet Explorer 中无效。</p> <div></div> </body> </html>
语法:spa
animation: name duration timing-function delay iteration-count direction;
值 | 描述 |
---|---|
animation-name | 规定须要绑定到选择器的 keyframe 名称。 |
animation-duration | 规定完成动画所花费的时间,以秒或毫秒计。ssr (注:默认时长为 0,不会播放动画了)code |
animation-timing-function | 规定动画的速度曲线。 |
animation-delay | 规定在动画开始以前的延迟。 |
animation-iteration-count | 规定动画应该播放的次数。 |
animation-direction | 规定是否应该轮流反向播放动画。 |