animation-fill-mode属性怎么用


本文摘自PHP中文网,作者青灯夜游,侵删。

animation-fill-mode属性是用于当动画不播放时(当动画完成时,或当动画有一个延迟未开始播放时),要应用到元素的样式,即其动画效果是否可见。

CSS3 animation-fill-mode属性

作用:animation-fill-mode 属性规定动画在播放之前或之后,其动画效果是否可见。

说明:默认情况下,CSS 动画在第一个关键帧播放完之前不会影响元素,在最后一个关键帧完成后停止影响元素。animation-fill-mode 属性可重写该行为。

语法:

1

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

none:不改变默认行为。

forwards: 当动画完成后,保持最后一个属性值(在最后一个关键帧中定义)。

backwards:在 animation-delay 所指定的一段时间内,在动画显示之前,应用开始属性值(在第一个关键帧中定义)。

both:向前和向后填充模式都被应用。

注:Internet Explorer 9 以及更早的版本不支持 animation-fill-mode 属性。

CSS3 animation-fill-mode属性的使用示例

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title></title>

<style>

div

{

    width:100px;

    height:100px;

    background:red;

    position:relative;

    animation:mymove 3s;

    animation-iteration-count:2;

    animation-fill-mode:forwards;

 

    /* Safari 和 Chrome */

    -webkit-animation:mymove 3s;

    -webkit-animation-iteration-count:2;

    -webkit-animation-fill-mode:forwards;

}

 

@keyframes mymove

{

    from {top:0px;}

    to {top:200px;}

}

 

@-webkit-keyframes mymove /* Safari 和 Chrome */

{

    from {top:0px;}

    to {top:200px;}

}

</style>

</head>

<body>

 

<div></div>

 

</body>

</html>

效果图:

1.gif

以上就是本篇文章的全部内容,希望能对大家的学习有所帮助。更多精彩内容大家可以关注php中文网相关教程栏目!!!

以上就是animation-fill-mode属性怎么用的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

css中伪类和伪元素的详细介绍(代码示例)

animation-iteration-count属性怎么用

css3有什么用

css实现页面底部固定的方法介绍(附代码)

css3新增的伪类有哪些

css3动画属性有哪些

text-emphasis属性有什么用

css实现基于用户滚动应用(代码)

layui自定义滑动弹窗动画

css3 transition-duration属性怎么用

更多相关阅读请进入《animation-fill-mode属性》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...