animation-fill-mode

介绍

animation-fill-mode 设置 CSS 动画在执行之前和之后如何将样式应用于其目标

使用示例

语法

/* Single animation */
animation-fill-mode: none;
animation-fill-mode: forwards;
animation-fill-mode: backwards;
animation-fill-mode: both;

/* Multiple animations */
animation-fill-mode: none, backwards;
animation-fill-mode: both, forwards, none;

取值

none

当动画未执行时,动画将不会将任何样式应用于目标,而是已经赋予给该元件的 CSS 规则来显示该元件。这是默认值。

forwards

动画结束时将最后一个关键帧的值设置给 View。最后一个关键帧取决于 animation-directionanimation-iteration-count 的值:

animation-directionanimation-iteration-countlast keyframe encountered
normaleven or odd100% or to
reverseeven or odd0% or from
alternateeven0% or from
alternateodd100% or to
alternate-reverseeven100% or to
alternate-reverseodd0% or from

backwards

动画开始时将第一个关键帧的值设置给 View。第一个关键帧取决于 animation-directionanimation-iteration-count 的值:

animation-directionfirst relevant keyframe
normal or alternate0% or from
reverse or alternate-reverse100% or to

both

动画将遵循 forwards 和 backwards 的规则,从而在动画开始与结束时将相应关键帧设置给 View。

形式定义

初始值none
适用元素all elements
是否支持继承no
是否支持动画no

形式语法

/*none*/
animation-fill-mode: none | forwards | backwards | both;

扩展阅读

兼容性

LCD tables only load in the browser

除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。