bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/CSS/Advanced Styling
CSS•Advanced Styling

CSS 3D Transforms

The CSS transform property applies a 2D or 3D transformation to an element. This property allows you to rotate, scale, move, and skew elements.

Mouse over the elements below to see the difference between a 2D and a 3D transformation:

CSS 3D Transforms Functions

With the CSS transform property you can use the following 3D transformation functions:

  • rotateX()
  • rotateY()
  • rotateZ()

The CSS rotateX() Function

The rotateX() function rotates an element around its X-axis at a given degree:

Example

Formatted code
#myDiv {
  transform: rotateX(150deg);
}

Live preview

The CSS rotateY() Function

The rotateY() function rotates an element around its Y-axis at a given degree:

Example

Formatted code
#myDiv {
  transform: rotateY(150deg);
}

Live preview

The CSS rotateZ() Function

The rotateZ() function rotates an element around its Z-axis at a given degree:

Example

Formatted code
#myDiv {
  transform: rotateZ(90deg);
}

Live preview

CSS Transform Properties

The following table lists all the 3D transform properties:

PropertyDescription
transformApplies a 2D or 3D transformation to an element
transform-originAllows you to change the position on transformed elements
transform-styleSpecifies how nested elements are rendered in 3D space
perspectiveSpecifies the perspective on how 3D elements are viewed
perspective-originSpecifies the bottom position of 3D elements
backface-visibilityDefines whether or not an element should be visible when not facing the screen

CSS 3D Transform Functions

FunctionDescription
matrix3d()Defines a 3D transformation, using a 4x4 matrix of 16 values
translate3d()Defines a 3D translation
translateZ()Defines a 3D translation, using only the value for the Z-axis
scale3d()Defines a 3D scale transformation
scaleZ()Defines a 3D scale transformation by giving a value for the Z-axis
rotate3d()Defines a 3D rotation
rotateX()Defines a 3D rotation along the X-axis
rotateY()Defines a 3D rotation along the Y-axis
rotateZ()Defines a 3D rotation along the Z-axis
perspective()Defines a perspective view for a 3D transformed element

Previous

CSS 2D Transform Skew / Matrix

Next

CSS Transitions

This chapter

Overview
53

Lessons

154m

Read time

1. CSS Rounded Corners2. Sass Tutorial3. CSS Border Images4. CSS Multiple Backgrounds5. CSS Background Size6. CSS Background Origin7. CSS Background Clip8. CSS Colors9. CSS Color Keywords10. CSS Gradients11. CSS Radial Gradients12. CSS Conic Gradients13. CSS Shadow Effects14. CSS Box Shadow15. CSS Text Effects16. CSS Custom Fonts17. CSS 2D Transforms18. CSS 2D Transform Scale19. CSS 2D Transform Skew / Matrix20. CSS 3D Transforms21. CSS Transitions22. CSS Transition Timing23. CSS Animations24. CSS Animation Timing25. CSS Animation Properties26. CSS Tooltip27. CSS Tooltip Arrows28. CSS Styling Images29. CSS Image Effects30. CSS Image Hover Overlays31. CSS Responsive Modal Images32. CSS Centering Images33. CSS Image Filter Effects34. CSS Image Shapes35. CSS object-fit Property36. CSS object-position Property37. CSS Masking38. CSS Gradient Mask Layers39. CSS SVG Mask Layers40. CSS Styling Buttons41. CSS Button Hover Effects42. CSS Button Groups43. CSS Pagination Styles44. CSS Multiple Columns45. CSS Column Rules46. CSS User Interface47. CSS Variables - var() Function48. CSS Overriding Variables49. CSS Variables and JavaScript50. CSS Variables in Media Queries51. CSS @property Rule52. CSS Box Sizing53. CSS Media Queries

On this page

CSS 3D Transforms FunctionsThe CSS rotateX() FunctionThe CSS rotateY() FunctionThe CSS rotateZ() FunctionCSS Transform PropertiesCSS 3D Transform Functions