blob: 826a6e12fc9ec1236eaaebb6f412cd436159f358 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
---
title: skew()
slug: Web/CSS/transform-function/skew()
tags:
- CSS
- CSS 関数
- CSS 座標変換
- 関数
- リファレンス
browser-compat: css.types.transform-function.skew
translation_of: Web/CSS/transform-function/skew()
---
{{CSSRef}}
**`skew()`** は [CSS](/ja/docs/Web/CSS) [関数](/ja/docs/Web/CSS/CSS_Functions)で、要素を二次元平面上でゆがめる変換を定義します。結果は {{cssxref("<transform-function>")}} データ型になります。
{{EmbedInteractiveExample("pages/css/function-skew.html")}}
この変換はシアー変形 ({{interwiki('wikipedia', 'せん断写像')}}) で、要素内のそれぞれの点を水平および垂直方向に指定された角度でゆがませます。要素のそれぞれの角を掴んで、一定の角度に沿って引っ張ったような効果があります。
それぞれの点の座標は、指定された角度と原点からの距離に比例した値によって変更されます。よって、原点から遠くなるにしたがって、加えられる値が大きくなります。
## 構文
`skew()` 関数は 1 つまたは 2 つの値を指定し、それぞれの軸に適用されるゆがみの量を表します。1 つだけ値を設定した場合は X 軸に使用され、 Y 軸方向の変形は行いません。
```css
skew(ax)
skew(ax, ay)
```
### 値
- `ax`
- : {{cssxref("<angle>")}} で、 X 軸 (横座標) 方向にゆがめるのに使用する角度を表します。
- `ay`
- : {{cssxref("<angle>")}} で、 Y 軸 (縦座標) 方向にゆがめるのに使用する角度を表します。定義されていない場合、既定値は `0` となり、水平方向にのみゆがめます。
<table class="standard-table">
<thead>
<tr>
<th scope="col">ℝ^2 のデカルト座標</th>
<th scope="col">ℝℙ^2 の同次座標</th>
<th scope="col">ℝ^3 のデカルト座標</th>
<th scope="col">ℝℙ^3 の同次座標</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="2">
<math
><mfenced
><mtable
><mtr
><mtd><mn>1</mn> </mtd
><mtd
><mo>tan</mo>
<mo>(</mo>
<mi>ax</mi>
<mo>)</mo>
</mtd></mtr
><mtr
><mtd
><mo>tan</mo>
<mo>(</mo>
<mi>ay</mi>
<mo>)</mo> </mtd
><mtd><mn>1</mn></mtd></mtr
></mtable
></mfenced
></math
>
</td>
<td>
<math
><mfenced
><mtable
><mtr
><mtd><mn>1</mn> </mtd
><mtd
><mo>tan</mo>
<mo>(</mo>
<mi>ax</mi>
<mo>)</mo> </mtd
><mtd><mn>0</mn> </mtd></mtr
><mtr
><mtd
><mo>tan</mo>
<mo>(</mo>
<mi>ay</mi>
<mo>)</mo> </mtd
><mtd><mn>1</mn> </mtd><mtd><mn>0</mn> </mtd></mtr
><mtr
><mtd><mn>0</mn> </mtd><mtd><mn>0</mn> </mtd
><mtd><mn>1</mn></mtd></mtr
><mtr></mtr></mtable></mfenced
></math>
</td>
<td rowspan="2">
<math
><mfenced
><mtable
><mtr
><mtd><mn>1</mn> </mtd
><mtd
><mo>tan</mo>
<mo>(</mo>
<mi>ax</mi>
<mo>)</mo> </mtd
><mtd><mn>0</mn> </mtd></mtr
><mtr
><mtd
><mo>tan</mo>
<mo>(</mo>
<mi>ay</mi>
<mo>)</mo> </mtd
><mtd><mn>1</mn> </mtd><mtd><mn>0</mn> </mtd></mtr
><mtr
><mtd><mn>0</mn> </mtd><mtd><mn>0</mn> </mtd
><mtd><mn>1</mn></mtd></mtr
></mtable
></mfenced
></math
>
</td>
<td rowspan="2">
<math
><mfenced
><mtable
><mtr
><mtd><mn>1</mn> </mtd
><mtd
><mo>tan</mo>
<mo>(</mo>
<mi>ax</mi>
<mo>)</mo> </mtd
><mtd><mn>0</mn> </mtd><mtd><mn>0</mn> </mtd></mtr
><mtr
><mtd
><mo>tan</mo>
<mo>(</mo>
<mi>ay</mi>
<mo>)</mo> </mtd
><mtd><mn>1</mn> </mtd><mtd><mn>0</mn> </mtd
><mtd><mn>0</mn> </mtd></mtr
><mtr
><mtd><mn>0</mn> </mtd><mtd><mn>0</mn> </mtd
><mtd><mn>1</mn> </mtd><mtd><mn>0</mn> </mtd></mtr
><mtr
><mtd><mn>0</mn> </mtd><mtd><mn>0</mn> </mtd
><mtd><mn>0</mn> </mtd><mtd><mn>1</mn></mtd></mtr
></mtable
></mfenced
></math
>
</td>
</tr>
<tr>
<td><code>[1 tan(ay) tan(ax) 1 0 0]</code></td>
</tr>
</tbody>
</table>
## 例
<h3 id="Skewing_on_the_x-axis_only">X 軸のみの変形</h3>
#### HTML
```html
<div>Normal</div>
<div class="skewed">Skewed</div>
```
#### CSS
```css
body {
margin: 20px;
}
div {
width: 80px;
height: 80px;
background-color: skyblue;
}
.skewed {
transform: skew(10deg); /* Equal to skewX(10deg) */
background-color: pink;
}
```
#### 結果
{{EmbedLiveSample("Skewing_on_the_x-axis_only", 200, 200)}}
<h3 id="Skewing_on_both_axes">両方の軸の変形</h3>
#### HTML
```html
<div>Normal</div>
<div class="skewed">Skewed</div>
```
#### CSS
```css
body {
margin: 20px;
}
div {
width: 80px;
height: 80px;
background-color: skyblue;
}
.skewed {
transform: skew(10deg, 10deg);
background-color: pink;
}
```
#### 結果
{{EmbedLiveSample("Skewing_on_both_axes", 200, 200)}}
## 仕様書
{{Specifications}}
## ブラウザーの互換性
{{Compat}}
## 関連情報
- {{cssxref("transform")}}
- {{cssxref("<transform-function>")}}
- [skewX()](/ja/docs/Web/CSS/transform-function/skewX())
- [skewY()](/ja/docs/Web/CSS/transform-function/skewY())
|