transition过渡-transition
微信小程序交流群:111733917 | 微信小程序从0基础到就业的课程:https://edu.csdn.net/topic/huangjuhua
通用语法
浏览器支持
Internet Explorer 10、Firefox、Opera 和 Chrome 支持 transition 属性。
Safari 支持替代的 -webkit-transition 属性。
注释:Internet Explorer 9 以及更早版本的浏览器不支持 transition 属性。
定义和用法
transition 属性是一个简写属性,用于设置四个过渡属性:
transition-property
transition-duration
transition-timing-function
transition-delay
注释:请始终设置 transition-duration 属性,否则时长为 0,就不会产生过渡效果。
默认值: all 0 ease 0
继承性: no
版本: CSS3
JavaScript 语法: object.style.transition=“width 2s”
语法
transition: property duration timing-function delay;
实例
<!DOCTYPE html>
<html>
<head>
<style>
div
{
width:100px;
height:100px;
background:blue;
transition:width 2s;
-moz-transition:width 2s; /* Firefox 4 */
-webkit-transition:width 2s; /* Safari and Chrome */
-o-transition:width 2s; /* Opera */
}
div:hover
{
width:300px;
}
</style>
</head>
<body>
<div></div>
<p>请把鼠标指针移动到蓝色的 div 元素上,就可以看到过渡效果。</p>
<p><b>注释:</b>本例在 Internet Explorer 中无效。</p>
</body>
</html>
效果图
小程序应用
Wxml代码
<view class='c01'>
查看过渡效果
</view>
Wxss代码
.c01{
margin: 10px;
padding: 10px;
height: 100px;
width: 100px;
background-color: gainsboro;
border-radius: 10px;
transition:width 2s;
}
.c01:hover{
width: 200px;
}