W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
屬性 | |||||
---|---|---|---|---|---|
animation-timing-function | 43.0 4.0 -webkit- | 10.0 | 16.0 5.0 -moz- | 9.0 4.0 -webkit- | 30.0 15.0 -webkit- 12.0 -o- |
animation-timing-function指定動畫將如何完成一個周期。
速度曲線定義動畫從一套 CSS 樣式變?yōu)榱硪惶姿玫臅r間。
速度曲線用于使變化更為平滑。
默認值: | ease |
---|---|
繼承: | no |
版本: | CSS3 |
JavaScript 語法: | object object.style.animationTimingFunction="linear" |
animation-timing-function使用的數(shù)學(xué)函數(shù),稱為三次貝塞爾曲線,速度曲線。使用此函數(shù),您可以使用您自己的值,或使用預(yù)先定義的值之一:
值 | 描述 |
---|---|
linear | 動畫從頭到尾的速度是相同的。 |
ease | 默認。動畫以低速開始,然后加快,在結(jié)束前變慢。 |
ease-in | 動畫以低速開始。 |
ease-out | 動畫以低速結(jié)束。 |
ease-in-out | 動畫以低速開始和結(jié)束。 |
cubic-bezier(n,n,n,n) | 在 cubic-bezier 函數(shù)中自己的值。可能的值是從 0 到 1 的數(shù)值。 |
提示: 請試著在下面的"嘗試一下"功能中使用不同的值。
從開始到結(jié)束以相同的速度播放動畫:
animation-timing-function:linear;
-webkit-animation-timing-function:linear; /* Safari and Chrome */
為了更好地理解不同的定時函數(shù)值,這里提供了設(shè)置五個不同值的五個不同的 div 元素:
/* W3C and Opera: */
#div1 {animation-timing-function: linear;}
#div2 {animation-timing-function: ease;}
#div3 {animation-timing-function: ease-in;}
#div4 {animation-timing-function: ease-out;}
#div5 {animation-timing-function: ease-in-out;}
/* Firefox: */
#div1 {-moz-animation-timing-function: linear;}
#div2 {-moz-animation-timing-function: ease;}
#div3 {-moz-animation-timing-function: ease-in;}
#div4 {-moz-animation-timing-function: ease-out;}
#div5 {-moz-animation-timing-function: ease-in-out;}
/* Safari and Chrome: */
#div1 {-webkit-animation-timing-function: linear;}
#div2 {-webkit-animation-timing-function: ease;}
#div3 {-webkit-animation-timing-function: ease-in;}
#div4 {-webkit-animation-timing-function: ease-out;}
#div5 {-webkit-animation-timing-function: ease-in-out;}
嘗試一下 ?與上例相同,但是通過 cubic-bezier 函數(shù)來定義速度曲線:
/* W3C and Opera: */
#div1 {animation-timing-function: cubic-bezier(0,0,1,1;}
#div2 {animation-timing-function: cubic-bezier(0.25,0.1,0.25,1);}
#div3 {animation-timing-function: cubic-bezier(0.42,0,1,1);}
#div4 {animation-timing-function: cubic-bezier(0,0,0.58,1);}
#div5 {animation-timing-function: cubic-bezier(0.42,0,0.58,1);}
/* Firefox: */
#div1 {-moz-animation-timing-function: cubic-bezier(0,0,1,1;}
#div2 {-moz-animation-timing-function: cubic-bezier(0.25,0.1,0.25,1);}
#div3 {-moz-animation-timing-function: cubic-bezier(0.42,0,1,1);}
#div4 {-moz-animation-timing-function: cubic-bezier(0,0,0.58,1);}
#div5 {-moz-animation-timing-function: cubic-bezier(0.42,0,0.58,1);}
/* Safari and Chrome: */
#div1 {-webkit-animation-timing-function: cubic-bezier(0,0,1,1;}
#div2 {-webkit-animation-timing-function: cubic-bezier(0.25,0.1,0.25,1);}
#div3 {-webkit-animation-timing-function: cubic-bezier(0.42,0,1,1);}
#div4 {-webkit-animation-timing-function: cubic-bezier(0,0,0.58,1);}
#div5 {-webkit-animation-timing-function: cubic-bezier(0.42,0,0.58,1);}
CSS3 教程: CSS3 動畫
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: