transition

过渡

英 [trænˈzɪʃn]   美 [trænˈzɪʃən, -ˈsɪʃ-]

css transition属性 语法

作用:transition 属性是一个简写属性,用于设置四个过渡属性:transition-property   transition-duration  transition-timing-function  transition-delay

语法:transition: property duration timing-function delay;

说明:transition-property    规定设置过渡效果的 CSS 属性的名称。    transition-duration    规定完成过渡效果需要多少秒或毫秒。    transition-timing-function    规定速度效果的速度曲线。    transition-delay    定义过渡效果何时开始。    

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

css transition属性 示例

<!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>

运行实例 »

点击 "运行实例" 按钮查看在线实例

热门推荐