animation
英[??n??me??n]? ?美[??n??me??n]??
n.生氣,活潑;卡通製作,卡通攝製;[影視]卡通片
複數(shù): animations
direction
英[d??rek?n]? ?美[d??r?k??n, da?-]??
##n.方向趨勢(shì);方面;用法說(shuō)明複數(shù): directions
CSS動(dòng)畫(huà)方向?qū)傩?語(yǔ)法
animation-direction屬性怎麼用?
animation-direction屬性是用來(lái)定義是否應(yīng)該輪流反向播放動(dòng)畫(huà)的;當(dāng)動(dòng)畫(huà)播放次數(shù)超過(guò)一次時(shí),我們就可以透過(guò)設(shè)定animation-direction的值為alternate來(lái)實(shí)現(xiàn)動(dòng)畫(huà)輪流反向播放。
作用:定義是否應(yīng)該輪流反向播放動(dòng)畫(huà)。
語(yǔ)法:animation-direction: normal|alternate;
說(shuō)明:normal ? ?預(yù)設(shè)值。動(dòng)畫(huà)應(yīng)該可以正常播放。 alternate ? ?動(dòng)畫(huà)應(yīng)該輪流反向播放。? ??
註解:如果動(dòng)畫(huà)設(shè)定為只播放一次,則該屬性沒(méi)有效果。
CSS動(dòng)畫(huà)方向?qū)傩?範(fàn)例
<!DOCTYPE html> <html> <head> <style> div { width:100px; height:100px; background:red; position:relative; animation:myfirst 5s infinite; animation-direction:alternate; /* Safari and Chrome */ -webkit-animation:myfirst 5s infinite; -webkit-animation-direction:alternate; } @keyframes myfirst { 0% {background:red; left:0px; top:0px;} 25% {background:yellow; left:200px; top:0px;} 50% {background:blue; left:200px; top:200px;} 75% {background:green; left:0px; top:200px;} 100% {background:red; left:0px; top:0px;} } @-webkit-keyframes myfirst /* Safari and Chrome */ { 0% {background:red; left:0px; top:0px;} 25% {background:yellow; left:200px; top:0px;} 50% {background:blue; left:200px; top:200px;} 75% {background:green; left:0px; top:200px;} 100% {background:red; left:0px; top:0px;} } </style> </head> <body> <p><strong>注釋?zhuān)?lt;/strong>Internet Explorer 9 以及更早的版本不支持 animation-direction 屬性。</p> <div></div> </body> </html>
執(zhí)行實(shí)例 ?
點(diǎn)擊 "執(zhí)行實(shí)例" 按鈕查看線上實(shí)例