CSS 3D Transforms

Using with 3d transforms, we can move element to x-axis, y-axis and z-axis, Below example clearly specifies how the element will rotate

3D Transforms were first implemented by the Safari/WebKit team ages ago. Support in other browsers is still variable, but getting better.

CSS allows you to format your elements using 3D transformations.

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

CSS 3D Transforms

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

The rotateX() Method

Example -

The rotateY() Method

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

The rotateZ() Method

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

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

3D Transform Methods

FunctionDescription
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