animation

英 [??n??me??n]? ?美 [??n??me??n]??

n.生氣,活潑;動(dòng)畫片制作,動(dòng)畫片攝制;[影視]動(dòng)畫片

復(fù)數(shù): animations

direction

英 [d??rek?n]? ?美 [d??r?k??n, da?-]??

n.方向;趨勢(shì);方面;用法說(shuō)明

復(fù)數(shù): directions

css3 animation-direction屬性 語(yǔ)法

作用:定義是否應(yīng)該輪流反向播放動(dòng)畫。

語(yǔ)法:animation-direction: normal|alternate;

說(shuō)明:normal ? ?默認(rèn)值。動(dòng)畫應(yīng)該正常播放。alternate ? ?動(dòng)畫應(yīng)該輪流反向播放。? ??

注釋:如果把動(dòng)畫設(shè)置為只播放一次,則該屬性沒(méi)有效果。

當(dāng)動(dòng)畫播放次數(shù)超過(guò)一次時(shí),我們可以通過(guò)設(shè)置animation-direction的值為alternate來(lái)實(shí)現(xiàn)動(dòng)畫輪流反向播放。默認(rèn)情況下,該屬性值為normal,表示動(dòng)畫正常播放

css3 animation-direction屬性 示例

<!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>注釋:</strong>Internet Explorer 9 以及更早的版本不支持 animation-direction 屬性。</p>

<div></div>

</body>
</html>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例