translateZ()函數是一個內置函數,用於在3D空間中沿z軸重新定位元素。
用法:
translateZ( t )
參數:該函數接受單個參數t,該參數保存與z軸對應的平移長度。
以下示例說明了CSS中的translateZ()函數:
範例1:
<!DOCTYPE html>
<html>
<head>
<title>
CSS translateZ() function
</title>
<style>
body {
text-align:center;
}
h1 {
color:green;
}
.translateZ_image {
transform:perspective(200px) translateZ(100px);
}
</style>
</head>
<body>
<h1>GeeksforGeeks</h1>
<h2>CSS translateZ() function</h2>
<h4>Original Image</h4>
<img src=
"https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"
alt="GeeksforGeeks logo">
<br>
<h4>Translated image</h4>
<img class="translateZ_image"
src=
"https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"
alt="GeeksforGeeks logo">
</body>
</html>
輸出:
範例2:
<!DOCTYPE html>
<html>
<head>
<title>
CSS translateZ() function
</title>
<style>
body {
text-align:center;
}
h1 {
color:green;
}
.GFG {
font-size:35px;
font-weight:bold;
color:green;
}
.geeks {
transform:perspective(
200px) translateZ(100px);
}
</style>
</head>
<body>
<h1>GeeksforGeeks</h1>
<h2>CSS translateZ() function</h2>
<h4>Original Element</h4>
<div class="GFG">
Welcome to GeeksforGeeks
</div>
<h4>Translated Element</h4>
<div class="GFG geeks">
Welcome to GeeksforGeeks
</div>
</body>
</html>
輸出:
支持的瀏覽器:translateZ()函數支持的瀏覽器如下:
- 穀歌瀏覽器
- IE瀏覽器
- 火狐瀏覽器
- 蘋果瀏覽器
- Opera
相關用法
- p5.js min()用法及代碼示例
- p5.js value()用法及代碼示例
- PHP pow( )用法及代碼示例
- p5.js hue()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- PHP next()用法及代碼示例
- PHP each()用法及代碼示例
- d3.js d3.min()用法及代碼示例
- p5.js pan()用法及代碼示例
- p5.js sin()用法及代碼示例
- d3.js d3.max()用法及代碼示例
- p5.js tan()用法及代碼示例
注:本文由純淨天空篩選整理自jit_t大神的英文原創作品 CSS | translateZ() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。