transition-property属性怎么用


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

transition-property属性是用于指定应用过渡效果的 CSS 属性的名称;当指定的 CSS 属性发生改变时,过渡效果将开始。

CSS3 transition-property属性

作用:transition-property 属性规定应用过渡效果的 CSS 属性的名称。(当指定的 CSS 属性改变时,过渡效果将开始)。

提示:过渡效果通常在用户将鼠标指针浮动到元素上时发生。

语法:

1

transition-property: none|all|property;

none:没有属性会获得过渡效果。

all:所有属性都将获得过渡效果。

property:定义应用过渡效果的 CSS 属性名称列表,列表以逗号分隔。

注:需要始终设置 transition-duration 属性,否则时长为 0,就不会产生过渡效果。

CSS3 transition-property属性的使用示例

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

44

45

46

47

48

49

50

51

52

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<style>

div

{

width:100px;

height:100px;

background:red;

margin: 10px 0px;

 

}

.demo1{

transition-property: width;

transition-duration: 2s;

-moz-transition-property: width; /* Firefox 4 */

-moz-transition-duration: 2s; /* Firefox 4 */

-webkit-transition-property: width; /* Safari and Chrome */

-webkit-transition-duration: 2s; /* Safari and Chrome */

-o-transition-property: width; /* Opera */

-o-transition-duration: 2s; /* Opera */

}

.demo2{

transition-property: height;

transition-duration: 2s;

-moz-transition-property: height; /* Firefox 4 */

-moz-transition-duration: 2s; /* Firefox 4 */

-webkit-transition-property: height; /* Safari and Chrome */

-webkit-transition-duration: 2s; /* Safari and Chrome */

-o-transition-property: height; /* Opera */

-o-transition-duration: 2s; /* Opera */

}

.demo1:hover

{

width:300px;

}

.demo2:hover

{

height:150px;

}

</style>

</head>

<body>

<p>请把鼠标指针移动到红色的 div 元素上,查看过渡效果。</p>

<p>width属性发生变化:</p>

<div class="demo1"></div>

<p>height属性发生变化:</p>

<div class="demo2"></div>

<p><b>注释:</b>本例在 Internet Explorer 中无效。</p>

</body>

</html>

效果图:

1.gif

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

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

相关阅读 >>

css3支持为网页添加多个背景图片吗

animation-direction属性怎么用

css <basic-shape>的基本形状函数有哪些?如何使用?

css3 icon属性怎么用?

用h5和css3制作全屏背景轮换播放教程

css中resize属性有什么用

通过案例,了解css3创建简单动画的方法

css3有什么用

css3怎么设置元素背面不可见

你值得了解的一种css获取图片主题色的小技巧(分享)

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




打赏

取消

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

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

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

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

评论

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

    暂无评论...