本文主要包含css3,css3-animation,逐帧动画等相关知识,我_爱编程  希望在学习及工作中可以帮助到您
  本文分享了用css3-animation来制作逐帧动画的实现方法,供大家参考,具体内容如下
常见用法:
- :hover{ animation:mymove 4s ease-out 1s backwards;}
 - @-webkit-keyframes mymove /*Safari and Chrome*/ { from {left:0px;} to {left:200px;} }
 - 复制代码
 - 解释:
 - mymove :keyframes的名称;
 - 4s:动画的总时间;
 - ease-out: 快结束的时候慢下来;
 - 1s:停顿1秒后开始动画;
 - backwards:动画结束后回到原点
 - 默认:播放一次
 - 或者
 - transition:left 4s ease-out
 - :hover{left:200px}
 
兼容主流浏览器:
- .test{
 - -webkit-animation: < 各种属性值 >;
 - -moz-animation: < 各种属性值 >;
 - -o-animation: < 各种属性值 >;
 - animation: < 各种属性值 >;
 - }
 
animation-name,规定要绑定的keyframes的名称,随便你取,不过为了日后维护的方便,建议取一个跟动作相关名称相近的名称比较好。比如要我们要绑定一个跑的动作,那么可以命名为run。
time,这里有两个时间,前面一个是规定完成这个动画所需要的时间,全称叫animation-duration,第二个time为动画延迟开始播放的时间,全称叫animation-delay,这两个数值可以用秒’s’也可以用微秒’ms’来写,1000ms=1s,这个不用一一介绍。
animation-timing-function,规定动画的运动曲线,这里有9个值,分别是ease| linear | ease-in | ease-out | ease-in-out | step-start | step-end | steps([, [ start | end ] ]?) | cubic-bezier(x1, y1, x2, y2)
ease:动画缓慢开始,接着加速,最后减慢,默认值;
linear:动画从头到尾的速度是相同的;
ease-in:以低速开始;
ease-out:以低速结束;
ease-in-out:动画以低速开始和结束;
效果一样 (按步数)steps
- .test1{
 - background:url(http://img.xiaoho.com/2014/12/test.png) no-repeat 0 0;
 - -webkit-animation:run 350ms steps(1) infinite 0s;}
 - @-webkit-keyframes run {
 - 0% {
 - background-position:0;
 - }
 - 20% {
 - background-position:-90px 0;
 - }
 - 40% {
 - background-position:-180px 0;
 - }
 - 60% {
 - background-position:-270px 0;
 - }
 - 80% {
 - background-position:-360px 0;
 - }
 - 100% {
 - background-position:-450px 0;
 - }
 - }
 - .test2{
 - background:url(http://img.xiaoho.com/2014/12/test.png) no-repeat 0 0;
 - -webkit-animation:run 350ms steps(5) infinite 0s;}
 - @-webkit-keyframes run {
 - 100% {
 - background-position:-450px 0;
 - }
 - }
 

