這篇文章介紹css3動畫2D、3D轉換的方法
css3動畫的2D、3D轉碼:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>css3動畫</title> <style type="text/css"> p{width:100px;height:100px;background: rebeccapurple;color:#fff;} .p1{ /*translate:移動(x,y)*/ transform:translate(100px,100px); -webkit-transform: translate(100px,100px);/*safari,chrome*/ -ms-transform: translate(100px,100px);/*IE*/ -o-transform:translate(100px,100px);/*opera*/ -moz-transform: translate(100px,100px);/*firefox*/ } .p2{ /*rotate:旋轉(旋轉角度edg)*/ transform:rotate(100deg); -webkit-transform:rotate(100deg);/*safari,chrome*/ } .p3{ /*scale:縮放(寬,高)*/ transform:scale(1,2); -webkit-transform:scale(1,2);/*safari,chrome*/ } .p4{ /*skew:傾斜(圍繞x軸旋轉,圍繞y軸旋轉)*/ transform:skew(20deg,20deg); -webkit-transform:skew(20deg,20deg);/*safari,chrome*/ } .p5{ /*matrix矩陣,定義 2D 轉換,使用六個值的矩陣 定義 3D 轉換,使用 16 個值的 4x4 矩陣*/ transform:matrix(0.586,0.8,-0.8,0.866,0,0); -webkit-transform: matrix(0.586,0.8,-0.8,0.866,0,0); } /*3D轉換*/ .p6{ /*rotateX:(圍繞x軸旋轉)*/ /*rotateY:(圍繞y軸旋轉)*/ transform:rotateX(120deg); -webkit-transform:rotateX(120deg);/*safari,chrome*/ } </style></head><body><p>這個是測試1</p><br/><p class="p1">這個是測試2</p><br/><p class="p2">這個是測試2</p><br/><p class="p3">這個是測試2</p><br/><p class="p4">這個是測試2</p><br/><p class="p5">這個是測試2</p><br/><p class="p6">這個是測試2</p><br/></body></html>