
- CSS 教程
- CSS - 首頁
- CSS - 路線圖
- CSS - 簡介
- CSS - 語法
- CSS - 選擇器
- CSS - 引入
- CSS - 測量單位
- CSS - 顏色
- CSS - 背景
- CSS - 字型
- CSS - 文字
- CSS - 圖片
- CSS - 連結
- CSS - 表格
- CSS - 邊框
- CSS - 塊級邊框
- CSS - 內聯邊框
- CSS - 外邊距
- CSS - 列表
- CSS - 內邊距
- CSS - 游標
- CSS - 輪廓
- CSS - 尺寸
- CSS - 捲軸
- CSS - 內聯塊級元素
- CSS - 下拉選單
- CSS - 可見性
- CSS - 溢位
- CSS - Clearfix
- CSS - 浮動
- CSS - 箭頭
- CSS - 調整大小
- CSS - 引號
- CSS - 順序
- CSS - 定位
- CSS - 連字元
- CSS - 懸停
- CSS - 顯示
- CSS - 焦點
- CSS - 縮放
- CSS - 平移
- CSS - 高度
- CSS - 連字元字元
- CSS - 寬度
- CSS - 不透明度
- CSS - Z-index
- CSS - 底部
- CSS - 導航欄
- CSS - 覆蓋層
- CSS - 表單
- CSS - 對齊
- CSS - 圖示
- CSS - 圖片庫
- CSS - 註釋
- CSS - 載入動畫
- CSS - 屬性選擇器
- CSS - 組合器
- CSS - 根元素
- CSS - 盒模型
- CSS - 計數器
- CSS - 剪輯
- CSS - 書寫模式
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - 隔離
- CSS - 滾動溢位
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - 指標事件
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS 高階
- CSS - 網格
- CSS - 網格佈局
- CSS - Flexbox
- CSS - 可見性
- CSS - 定位
- CSS - 圖層
- CSS - 偽類
- CSS - 偽元素
- CSS - @規則
- CSS - 文字效果
- CSS - 分頁媒體
- CSS - 列印
- CSS - 佈局
- CSS - 驗證
- CSS - 圖片精靈
- CSS - Important
- CSS - 資料型別
- CSS3 教程
- CSS3 - 教程
- CSS - 圓角
- CSS - 邊框圖片
- CSS - 多重背景
- CSS - 顏色
- CSS - 漸變
- CSS - 盒陰影
- CSS - 盒裝飾中斷
- CSS - Caret Color
- CSS - 文字陰影
- CSS - 文字
- CSS - 2D 變換
- CSS - 3D 變換
- CSS - 過渡
- CSS - 動畫
- CSS - 多列
- CSS - 盒尺寸
- CSS - 工具提示
- CSS - 按鈕
- CSS - 分頁
- CSS - 變數
- CSS - 媒體查詢
- CSS - 函式
- CSS - 數學函式
- CSS - 遮罩
- CSS - 形狀
- CSS - 樣式圖片
- CSS - 特異性
- CSS - 自定義屬性
- CSS 響應式
- CSS RWD - 簡介
- CSS RWD - 視口
- CSS RWD - 網格檢視
- CSS RWD - 媒體查詢
- CSS RWD - 圖片
- CSS RWD - 影片
- CSS RWD - 框架
- CSS 工具
- CSS - PX 到 EM 轉換器
- CSS - 顏色選擇器和動畫
- CSS 資源
- CSS - 有用資源
- CSS - 討論
CSS - 3D 變換
CSS 變換用於透過使用 translate、scale 和 rotate 等屬性在三維空間中為元素設定動畫。換句話說,這些函式允許您沿 X、Y 和 Z 軸旋轉、縮放和移動元素,為您的設計新增深度和透視感。
2D 變換
3D 變換
目錄
CSS 3D 平移
CSS 中的 **translate3d** 函式透過指定沿 X、Y 和 Z 軸的偏移量來在 3D 空間中移動元素,其中 Z 軸控制深度(朝向或遠離觀察者的距離)。以下示例顯示了一個在懸停時在 3D 空間中移動的盒子。**perspective** 屬性用於為 3D 效果提供深度感。
示例
<!DOCTYPE html> <html lang="en"> <head> <style> body { height: 300px; display: flex; justify-content: center; align-items: center; background-color: #f0f0f0; font-family: Arial, sans-serif; } /* Container with Perspective */ .container { perspective: 800px; } /* The Box Element */ .box { width: 200px; height: 200px; background-color: #4CAF50; color: white; display: flex; justify-content: center; align-items: center; font-size: 1.5em; border-radius: 10px; /* Initial 3D Transformation */ transform: translate3d(50px, 50px, 100px) rotateX(15deg) rotateY(25deg); transition: transform 0.6s ease; } /* Hover State with Different 3D Transformation */ .box:hover { transform: translate3d(-50px, -50px, -100px); background-color: #2ecc71; cursor: pointer; } </style> </head> <body> <div class="container"> <div class="box"> 3D Box </div> </div> </body> </html>
CSS 3D 旋轉
CSS 中的 **rotate3d** 函式允許您透過定義旋轉向量的 X、Y 和 Z 分量以及旋轉角度,在 3D 空間中圍繞指定軸旋轉元素。以下示例顯示了一個在懸停時在 3D 空間中旋轉的盒子,創造了動態的視覺效果。
示例
<!DOCTYPE html> <html lang="en"> <head> <style> body { height: 300px; display: flex; justify-content: center; align-items: center; background-color: #f0f0f0; font-family: Arial, sans-serif; } /* Container with Perspective */ .container { perspective: 800px; } /* The Box Element */ .box { width: 200px; height: 200px; background-color: #4CAF50; color: white; display: flex; justify-content: center; align-items: center; font-size: 1.5em; border-radius: 10px; /* Initial 3D Rotation */ transform: rotate3d(1, 1, 1, 45deg); transition: transform 0.6s ease; } /* Hover State with Different 3D Rotation */ .box:hover { transform: rotate3d(1, 1, 0, -45deg); background-color: #2ecc71; cursor: pointer; } </style> </head> <body> <div class="container"> <div class="box"> 3D Box </div> </div> </body> </html>
CSS 3D 縮放
CSS 中的 **scale3d** 函式透過指定沿 X、Y 和 Z 軸的縮放因子來在 3D 空間中縮放元素,允許進行統一或非統一縮放。以下示例顯示了一個在懸停時在 3D 空間中縮放的盒子,創造了視覺上吸引人的縮放效果。
示例
<!DOCTYPE html> <html lang="en"> <head> <style> body { height: 300px; display: flex; justify-content: center; align-items: center; background-color: #f0f0f0; font-family: Arial, sans-serif; } /* Container with Perspective */ .container { perspective: 800px; } /* The Box Element */ .box { width: 150px; height: 150px; background-color: #4CAF50; color: white; display: flex; justify-content: center; align-items: center; font-size: 1.5em; border-radius: 10px; /* Initial 3D Scaling */ transform: scale3d(1, 1, 1) rotate3d(1, 1, 0, -45deg); transition: transform 0.6s ease; } /* Hover State with Different 3D Scaling */ .box:hover { transform: scale3d(1.5, 1.5, 0.5); background-color: #2ecc71; cursor: pointer; } </style> </head> <body> <div class="container"> <div class="box"> 3D Box </div> </div> </body> </html>
CSS 3D 變換相關屬性
下表列出了用於在三維空間中變換元素的各種屬性。
屬性 | 描述 | 示例 |
---|---|---|
backface-visibility | 將元素背面的可見性設定為對使用者可見。 | |
perspective | 確定 z=0 平面與使用者之間的距離。 | |
perspective-origin | 確定使用者觀察 3D 定位元素的位置。 | |
rotate3d | 在三維空間中旋轉元素。 | |
scale | 在三維空間中縮放元素。 | |
transform | 在三維空間中變換元素。 | |
translate | 在三維空間中平移元素。 | |
rotateZ() | 圍繞 z 軸旋轉元素。 | |
scaleZ() | 沿 z 軸向上或向下縮放元素。 | |
translateZ() | 沿 z 軸向上或向下平移元素。 |
廣告