css3属性

transition 属性

定义和用法

transition 属性是一个简写属性,用于设置四个过渡属性:

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

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

<!DOCTYPE html>
<html>
<head>
<style>
div
{
100px;
height:100px;
background:blue;
transition:width 2s;
-moz-transition:width 2s; /* Firefox 4 */
-webkit-transition:width 2s; /* Safari and Chrome */
-webkit-transition:height 10s;
-o-transition:width 2s; /* Opera */
}

div:active
{
300px;
height:200px;
}
</style>
</head>
<body>

<div></div>

<p>请把鼠标指针移动到蓝色的 div 元素上,就可以看到过渡效果。</p>

<p><b>注释:</b>本例在 Internet Explorer 中无效。</p>

</body>
</html>

原文地址:https://www.cnblogs.com/geekjsp/p/5861464.html