animation-direction属性怎么用


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

animation-direction属性是用来定义是否应该轮流反向播放动画的;当动画播放次数超过一次时,我们就可以通过设置animation-direction的值为alternate来实现动画轮流反向播放。

CSS3 animation-direction属性

作用:定义是否应该轮流反向播放动画。

语法:

1

animation-direction: normal|alternate;

normal:默认值。动画应该正常播放。

alternate:动画应该轮流反向播放。

说明: 如果 animation-direction 值是 "alternate",则动画会在奇数次数(1、3、5 等等)正常播放,而在偶数次数(2、4、6 等等)向后播放。

注:如果把动画设置为只播放一次,则该属性没有效果。

CSS3 animation-direction属性的使用示例

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

42

43

<!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>

 

<div></div>

 

</body>

</html>

效果图:

1.gif

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

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

相关阅读 >>

css3多媒体查询的简单介绍(代码示例)

html5/css3专题 css3打造百度贴吧的3d翻牌效果的经典案例

css3的default伪类选择器使用详解

html如何取消文本选中

background-size属性怎么用

box-shadow属性的功能是什么

css3绘制一个圆圆的loading转圈动画实例分享

css3 sticky不生效怎么办

css3哪个是设置动画播放次数

关于老式浏览器兼容html5和css3的问题详解

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




打赏

取消

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

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

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

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

评论

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