CSS 3D 변환
CSS 3D 변환
CSS는 3D 변형도 지원합니다.
2D와 3D 변환의 차이점을 보려면 아래 요소 위로 마우스를 가져갑니다.
2D 회전
3D 회전
이 장에서는 다음 CSS 속성에 대해 배웁니다.
transform
브라우저 지원
표의 숫자는 속성을 완전히 지원하는 첫 번째 브라우저 버전을 지정합니다.
Property | |||||
---|---|---|---|---|---|
transform | 36.0 |
10.0 |
16.0 |
9.0 |
23.0 |
CSS 3D 변환 방법
CSS transform
속성을 사용하면 다음 3D 변형 방법을 사용할 수 있습니다.
rotateX()
rotateY()
rotateZ()
회전X() 메서드
이 rotateX()
메서드는 X축을 중심으로 요소를 지정된 각도로 회전합니다.
예시
#myDiv
{
transform: rotateX(150deg);
}
회전Y() 메서드
이 rotateY()
메서드는 Y축을 중심으로 요소를 지정된 각도로 회전합니다.
예시
#myDiv
{
transform: rotateY(150deg);
}
회전Z() 메서드
이 rotateZ()
메서드는 Z축을 중심으로 요소를 지정된 각도로 회전합니다.
예시
#myDiv
{
transform: rotateZ(90deg);
}
CSS 변환 속성
다음 표에는 모든 3D 변환 속성이 나열되어 있습니다.
Property | Description |
---|---|
transform | Applies a 2D or 3D transformation to an element |
transform-origin | Allows you to change the position on transformed elements |
transform-style | Specifies how nested elements are rendered in 3D space |
perspective | Specifies the perspective on how 3D elements are viewed |
perspective-origin | Specifies the bottom position of 3D elements |
backface-visibility | Defines whether or not an element should be visible when not facing the screen |
CSS 3D 변환 방법
Function | Description |
---|---|
matrix3d (n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n) |
Defines a 3D transformation, using a 4x4 matrix of 16 values |
translate3d(x,y,z) | Defines a 3D translation |
translateX(x) | Defines a 3D translation, using only the value for the X-axis |
translateY(y) | Defines a 3D translation, using only the value for the Y-axis |
translateZ(z) | Defines a 3D translation, using only the value for the Z-axis |
scale3d(x,y,z) | Defines a 3D scale transformation |
scaleX(x) | Defines a 3D scale transformation by giving a value for the X-axis |
scaleY(y) | Defines a 3D scale transformation by giving a value for the Y-axis |
scaleZ(z) | Defines a 3D scale transformation by giving a value for the Z-axis |
rotate3d(x,y,z,angle) | Defines a 3D rotation |
rotateX(angle) | Defines a 3D rotation along the X-axis |
rotateY(angle) | Defines a 3D rotation along the Y-axis |
rotateZ(angle) | Defines a 3D rotation along the Z-axis |
perspective(n) | Defines a perspective view for a 3D transformed element |