animation

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

n.生氣,活潑;卡通製作,卡通攝製;[影視]卡通片

複數(shù): animations

direction

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

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

複數(shù): directions

CSS3動(dòng)畫方向?qū)傩?語法

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

語法:animation-direction: normal|alternate;

說明:normal ? ?預(yù)設(shè)值。動(dòng)畫應(yīng)該可以正常播放。 alternate ? ?動(dòng)畫應(yīng)該輪流反向播放。? ??

註解:如果動(dòng)畫設(shè)定為只播放一次,則該屬性沒有效果。

當(dāng)動(dòng)畫播放次數(shù)超過一次時(shí),我們可以透過設(shè)定animation-direction的值為alternate來實(shí)現(xiàn)動(dòng)畫輪流反向播放。預(yù)設(shè)情況下,此屬性值為normal,表示動(dòng)畫正常播放

CSS3動(dòng)畫方向?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>注釋:</strong>Internet Explorer 9 以及更早的版本不支持 animation-direction 屬性。</p>

<div></div>

</body>
</html>

執(zhí)行實(shí)例 ?

點(diǎn)擊 "執(zhí)行實(shí)例" 按鈕查看線上實(shí)例