dd

animation-direction [播放方向]


语法

animation-direction: normal | reverse | alternate | alternate-reverse [, normal | reverse | alternate | alternate-reverse ]*; 指定对象动画运动的方向。
语法项目说明
初始值normal
适用于所有元素
可否继承
媒介视觉
版本CSS3.0

说明

检索或设置对象动画循环播放次数大于1次时,动画是否反向运动。

如果提供多个属性值,以逗号进行分隔。

取值

normal:正常方向。

reverse:动画反向运行,方向始终与normal相反。(FF14.0.1以下不支持)

alternate:动画会循环正反方向交替运动,奇数次(1、3、5……)会正常运动,偶数次(2、4、6……)会反向运动,即所有相关联的值都会反向。

alternate-reverse:动画从反向开始,再正反方向交替运动,运动方向始终与alternate定义的相反。(FF14.0.1以下不支持)

实例代码

CSS
.demo_box{
    -webkit-animation:f1 2s 0.5s 10 forwards linear;
    -moz-animation:f1 2s 0.5s 10 forwards linear;
    position:relative;
    left:10px;
    width:100px;
    height:100px;
    margin:10px 0;
    overflow:hidden;
}
.normal{ 
    -webkit-animation-direction:normal;
    -moz-animation-direction:normal;
}
.reverse{
    -webkit-animation-direction:reverse;
    -moz-animation-direction:reverse;
}
.alternate{
    -webkit-animation-direction:alternate;
    -moz-animation-direction:alternate;
}
.alternate-reverse{
    -webkit-animation-direction:alternate-reverse;
    -moz-animation-direction:alternate-reverse;
}
@-webkit-keyframes f1{
    0%{left:10px;}
    100%{left:500px;}
}
@-moz-keyframes f1{
    0%{left:10px;}
    100%{left:500px;}
}
HTML
<div class="demo_box normal">normal</div>
<div class="demo_box reverse">reverse</div>
<div class="demo_box alternate">alternate</div>
<div class="demo_box alternate-reverse">alternate-reverse</div>
运行一下 »

兼容性

IEFirefoxOperaSafariChrome
IE 10+Firefox 3.5+目前暂无版本支持Safari 10+Chrome 2.0+