css3 animation属性怎么用


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

css3 animation属性是一个简写属性,通过设置六个动画属性来实现动画效果。这六个属性分别为动画名称、动画时间、速度曲线、动画延迟、播放次数及动画是否反向播放。

css3 animation属性

作用:animation 属性是一个简写属性,用于设置六个动画属性。

语法:

1

animation: name duration timing-function delay iteration-count direction;

说明:animation 属性可以设置的六个动画属性分别为:

● animation-name:规定需要绑定到选择器的 keyframe 名称。

● animation-duration:规定完成动画所花费的时间,以秒或毫秒计。

● animation-timing-function :规定动画的速度曲线。

● animation-delay:规定在动画开始之前的延迟。

● animation-iteration-count:规定动画应该播放的次数。

● animation-direction:规定是否应该轮流反向播放动画。

注:需始终设置 animation-duration 属性,否则当时长为 0时,就不会播放动画了。

css3 animation属性的使用示例

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

<!DOCTYPE html>

<html>

<head>

<style>

div

{

width:100px;

height:100px;

background:red;

position:relative;

animation:mymove 5s infinite;

-webkit-animation:mymove 5s infinite; /*Safari and Chrome*/

}

 

@keyframes mymove

{

from {left:0px;}

to {left:200px;}

}

 

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

{

from {left:0px;}

to {left:200px;}

}

</style>

</head>

<body>

 

<p><strong>注释:</strong>Internet Explorer 9 以及更早的版本不支持 animation 属性。</p>

 

<div></div>

 

</body>

</html>

效果图:

1.gif

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

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

相关阅读 >>

css3常见新特性介绍

ie6不支持css3吗

css3新增选择器有哪些

彻底理解css中视觉格式化模型(附示例)

punctuation-trim属性怎么用

css3怎么加内边框

perspective属性怎么用

css3的文本阴影text-shadow属性应该如何使用

html5包含css3吗

perspective-origin属性怎么用

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




打赏

取消

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

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

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

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

评论

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