css3的transition属性的使用_html/css_WEB-ITnose
程序员文章站
2022-05-31 22:58:04
...
transition是将某个属性从一个属性值在指定的时间内平滑过渡到另一个属性值来实现动画效果.
这个属性一般搭配:hover来使
这个属性一般搭配:hover来使
下面看一个例子:鼠标放在div上,0.2s后将div元素的背景色用一秒的时间变成黄色,变化方式是linear
1 div{ background-color:red; transition:background-color 1s linear 0.2s;}2 div:hover{ background-color:yellow;}
思思博士
鼠标没放上去之前:
鼠标放上去0.2s后 的变化过程:
鼠标放上去的最终效果:
看到这里 大家对与这个属性的用法,心里面应该有了底了.
对于这个属性,每个参数都有一个对应的属性名,也就是说这个属性是可以拆开写的.
非简写形式:
1 /*div{ background-color:red; transition:background-color 1s linear 0.2s;}*/2 div{background-color:red; transition-property:background-color; transition-duration:1s; transition-timing-function:linear; transition-delay:0.2s}3 div:hover{ background-color:yellow;}
transition还可以过渡多个效果.
1 div{ background-color:red; color:black; height:50px; transition:background-color 1s linear,color 1s linear,height 1s linear;}2 3 div:hover{ background-color:yellow; color:#F00; height:100px;}
上一篇: python第一节课
下一篇: 最新国内手机号码匹配
推荐阅读
-
HTML5里的placeholder属性使用实例和美化显示效果的方法
-
HTML5中的Scoped属性使用实例
-
HTML5的download属性详细介绍和使用实例
-
CSS3与动画有关的属性transition、animation、transform对比(史上最全版)
-
html5的自定义data-*属性与jquery的data()方法的使用
-
深入解析HTML5使用SVG图像时的viewBox属性用法
-
HTML5中meta属性的使用方法
-
HTML5中的强制下载属性download使用实例解析
-
详解HTML5中rel属性的prefetch预加载功能使用
-
HTML5自定义data-* data(obj)属性和jquery的data()方法的使用