Safari 支持替代的 -webkit-transition 属性。
注释:Internet Explorer 9 以及更早版本的浏览器不支持 transition 属性。
transition 属性是一个简写属性,用于设置四个过渡属性:
{C}Ø {C}{C}transition-property
{C}Ø {C}{C}transition-duration
{C}Ø {C}{C}transition-timing-function
{C}Ø {C}{C}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>
<view class='c01'>
查看过渡效果
</view>
.c01{
margin: 10px;
padding: 10px;
height: 100px;
width: 100px;
background-color: gainsboro;
border-radius: 10px;
transition:width 2s;
}
.c01:hover{
width: 200px;
}