本文分享了用css3-animation來制作逐幀動畫的實現(xiàn)方法,供大家參考,具體內容如下
常見用法:
CSS Code復制內容到剪貼板
: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}
兼容主流瀏覽器:
CSS Code復制內容到剪貼板
.test{
-webkit-animation: < 各種屬性值 >;
-moz-animation: < 各種屬性值 >;
-o-animation: < 各種屬性值 >;
animation: < 各種屬性值 >;
}
animation-name,規(guī)定要綁定的keyframes的名稱,隨便你取,不過為了日后維護的方便,建議取一個跟動作相關名稱相近的名稱比較好。比如要我們要綁定一個跑的動作,那么可以命名為run。
time,這里有兩個時間,前面一個是規(guī)定完成這個動畫所需要的時間,全稱叫animation-duration,第二個time為動畫延遲開始播放的時間,全稱叫animation-delay,這兩個數(shù)值可以用秒’s’也可以用微秒’ms’來寫,1000ms=1s,這個不用一一介紹。
animation-timing-function,規(guī)定動畫的運動曲線,這里有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:動畫以低速開始和結束;
效果一樣 (按步數(shù))steps
CSS Code復制內容到剪貼板
.test1{
background:url(http://huoche.7234.cn/images/jb51/m3qhbx3rh20.png) no-repeat 0 0;
-webkit-animation:run 350ms steps(1) infinite 0s;}
@-webkit-keyframes run {
新聞熱點
疑難解答