animation
复合属性。检索或设置对象所应用的动画特效。
如果有多个属性值时以”,”隔开,适用于所有元素,包含伪对象:after
和:before
。
语法:
animation:<single-animation>[,<single-animation>]*
<single-animation> = <single-animation-name> || <time> || <single-animation-timing-function> || <time> || <single-animation-iteration-count> || <single-animation-direction> || <single-animation-fill-mode> || <single-animation-play-state>
注意: IE10及以上才支持
animation
动画,IE6~9不支持,其它浏览器稍低版本需要加上浏览器厂商前缀。
1.animation-name 检索或设置对象所应用的动画名称
必须与规则@keyframes
配合使用
eg:
@keyframes animations
animation-name:animations;
2.animation-duration 检索或设置对象动画的持续时间
animation-duration:3s;//动画完成使用的时间为3s
3.animation-timing-function 检索或设置对象动画的过渡类型
linear
:线性过渡。等同于贝塞尔曲线(0.0, 0.0, 1.0, 1.0)
ease
:平滑过渡。等同于贝塞尔曲线(0.25, 0.1, 0.25, 1.0)
ease-in
:由慢到快。等同于贝塞尔曲线(0.42, 0, 1.0, 1.0)
ease-out
:由快到慢。等同于贝塞尔曲线(0, 0, 0.58, 1.0)
ease-in-out
:由慢到快再到慢。等同于贝塞尔曲线(0.42, 0, 0.58, 1.0)
step-start
:等同于steps(1, start)
step-end
:等同于steps(1, end)
steps(<integer>[, [ start | end ] ]?)
:接受两个参数的步进函数。第一个参数必须为正整数,指定函数的步数。第二个参数取值可以是start
或end
,指定每一步的值发生变化的时间点。第二个参数是可选的,默认值为end
。cubic-bezier(<number>, <number>, <number>, <number>)
:特定的贝塞尔曲线类型,4个数值需在[0, 1]区间内
4.animation-delay 检索或设置对象动画延迟的时间
animation-delay:0.5s;//动画开始前延迟的时间为0.5s
5.animation-iteration-count 检索或设置对象动画的循环次数
animation-iteration-count: infinite | number;
infinite
:无限循环number
: 循环的次数
6.animation-direction 检索或设置对象动画在循环中是否反向运动
normal
:正常方向reverse
:反方向运行alternate
:动画先正常运行再反方向运行,并持续交替运行alternate-reverse
:动画先反运行再正方向运行,并持续交替运行
7.animation-play-state 检索或设置对象动画的状态
animation-play-state:running | paused;
running
:运动paused
: 暂停
animation-play-state:paused;//当鼠标经过时动画停止,鼠标移开动画继续执行
8.animation-fill-mode 检索或设置对象动画时间之外的状态
none
:默认值,不设置对象动画之外的状态forwards
:设置对象状态为动画结束时的状态backwards
:设置对象状态为动画开始时的状态both
:设置对象状态为动画开始或结束时的状态