温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

css3的transition属性的详细讲解

发布时间:2021-08-10 18:30:03 来源:亿速云 阅读:119 作者:chen 栏目:web开发

本篇内容主要讲解“css3的transition属性的详细讲解”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“css3的transition属性的详细讲解”吧!

transition是将某个属性从一个属性值在指定的时间内平滑过渡到另一个属性值来实现动画效果.
这个属性一般搭配:hover来使

下面看一个例子:鼠标放在div上,0.2s后将div元素的背景色用一秒的时间变成黄色,变化方式是linear

代码如下:


div{ background-color:red; transition:background-color 1s linear 0.2s;}
div:hover{ background-color:yellow;}
<div>思思博士</div>



鼠标没放上去之前:

css3的transition属性的详细讲解

鼠标放上去0.2s后 的变化过程:

css3的transition属性的详细讲解

鼠标放上去的最终效果:

css3的transition属性的详细讲解

看到这里 大家对与这个属性的用法,心里面应该有了底了.

对于这个属性,每个参数都有一个对应的属性名,也就是说这个属性是可以拆开写的.

非简写形式:

代码如下:


/*div{ background-color:red; transition:background-color 1s linear 0.2s;}*/
div{background-color:red; transition-property:background-color; transition-duration:1s; transition-timing-function:linear; transition-delay:0.2s}
div:hover{ background-color:yellow;}

transition还可以过渡多个效果.

代码如下:


div{ background-color:red; color:black; height:50px; transition:background-color 1s linear,color 1s linear,height 1s linear;}
div:hover{ background-color:yellow; color:#F00; height:100px;}

到此,相信大家对“css3的transition属性的详细讲解”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI