css3的transition效果和transfor效果示例介绍
(编辑:jimmy 日期: 2024/11/17 浏览:3 次 )
复制代码代码如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>css3的transition效果</title>
<style type="text/css">body{ background:#000;}
*{margin:0; padding:0; list-style:none; outline:none;}
div{ width:960px; margin:50px auto;}
li{ width:130px; height:450px; background:#fff; float:left; text-align:center; line-height:450px; border:1px solid #666; position:relative; border-radius:5px; box-shadow:0 0 5px #666; -webkit-transition:all 0.5s ease-in-out; -moz-transition:all 0.5s ease-in-out; transition:all 0.5s ease-in-out; -o-transition:all 0.5s ease-in-out;}
#card1{ -webkit-transform:rotate(-20deg);-moz-transform:rotate(-20deg);-ms-transform:rotate(-20deg);-o-transform:rotate(-20deg); left:130px; top:40px; z-index:1;}
#card2{ -webkit-transform:rotate(-10deg);-moz-transform:rotate(-10deg);-ms-transform:rotate(-10deg);-o-transform:rotate(-10deg); left:40px; top:15px; z-index:2;}
#card3{ z-index:6;}
#card4{ -webkit-transform:rotate(10deg); -moz-transform:rotate(10deg); -ms-transform:rotate(10deg);-o-transform:rotate(10deg); right:40px; top:15px; z-index:5;}
#card5{ -webkit-transform:rotate(20deg); -moz-transform:rotate(20deg); -ms-transform:rotate(20deg);-o-transform:rotate(20deg); right:130px; top:40px; z-index:4;}
#transform li:hover{ z-index:7;}
#card1:hover{ background:orange; -webkit-transform:scale(1.1) rotate(-18deg);-moz-transform:scale(1.1) rotate(-18deg); -ms-transform:scale(1.1) rotate(-18deg);-o-transform:scale(1.1) rotate(-18deg);}
#card2:hover{ border:5px solid red; -webkit-transform:scale(1.1) rotate(-8deg);-moz-transform:scale(1.1) rotate(-8deg); -ms-transform:scale(1.1) rotate(-8deg);-o-transform:scale(1.1) rotate(-8deg);}
#card3:hover{ -webkit-transform:scale(1.1) rotate(2deg);-moz-transform:scale(1.1) rotate(2deg); -ms-transform:scale(1.1) rotate(2deg);-o-transform:scale(1.1) rotate(2deg);}
#card4:hover{ -webkit-transform:scale(1.1) rotate(8deg);-moz-transform:scale(1.1) rotate(8deg); -ms-transform:scale(1.1) rotate(8deg);-o-transform:scale(1.1) rotate(8deg);}
#card5:hover{ -webkit-transform:scale(1.1) rotate(18deg);-moz-transform:scale(1.1) rotate(18deg); -ms-transform:scale(1.1) rotate(18deg);-o-transform:scale(1.1) rotate(18deg);}</style>
</head>
<body>
<div>
<ul id="transform">
<li id="card1">1</li>
<li id="card2">2</li>
<li id="card3">3</li>
<li id="card4">4</li>
<li id="card5">5</li>
</ul>
</div>
</body>
</html>
1.transform:变形
其属性有:rotate(10deg)旋转度数;skew(10deg)倾斜;scale(1.5)按比例缩放,负数为缩小,translate(120px,0)移位,向右移动120px,负数表示向左或向上
2.transition 允许css的属性值在一定的时间区间内平滑地过渡
transition:all(执行变换的属性) 0.5s(变换延续的时间) ease-in-out(变换的速率变化)
下一篇:css设置矢量图字体图标的方法(图解)