skew()函數是一個內置函數,用於在2D平麵中變換元素。傾斜元素是指選取一個點並沿不同方向推動或拉動它。
用法:
skew( ax )
或者
skew( ax, ay )
參數:
- ax:此參數保持代表水平軸的角度以使元素變形。
- ay:此參數保持代表垂直軸的角度以使元素變形。如果未定義,則默認值為零。這意味著在x方向上完全偏斜。
以下示例說明了CSS中的skew()函數:
範例1:
<!DOCTYPE html>
<html>
<head>
<title>CSS skew() function</title>
<style>
body {
text-align:center;
}
h1 {
color:green;
}
.skew_image {
transform-origin:top left;
transform:skew(30deg, 0);
}
</style>
</head>
<body>
<h1>GeeksforGeeks</h1>
<h2>CSS skew() function</h2>
<img class="skew_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 skew() function</title>
<style>
body {
text-align:center;
}
h1 {
color:green;
}
.GFG {
font-size:35px;
font-weight:bold;
color:green;
transform:skew(45deg);
}
</style>
</head>
<body>
<h1>GeeksforGeeks</h1>
<h2>CSS skew() function</h2>
<div class="GFG">Welcome to GeeksforGeeks</div>
</body>
</html>
輸出:
支持的瀏覽器:skew()函數支持的瀏覽器如下:
- 穀歌瀏覽器
- IE瀏覽器
- 火狐瀏覽器
- 蘋果瀏覽器
- Opera
相關用法
- PHP end()用法及代碼示例
- d3.js d3.set.has()用法及代碼示例
- d3.js d3.lab()用法及代碼示例
- d3.js d3.set.add()用法及代碼示例
- PHP cos( )用法及代碼示例
- CSS hsl()用法及代碼示例
- PHP sin( )用法及代碼示例
- p5.js int()用法及代碼示例
- p5.js hue()用法及代碼示例
- p5.js red()用法及代碼示例
- PHP Ds\Set xor()用法及代碼示例
- p5.js min()用法及代碼示例
注:本文由純淨天空篩選整理自jit_t大神的英文原創作品 CSS | skew() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。