CSS translate3d() Function

The CSS translate3d() function is used to move elements in a three-dimensional space.

The translate3d() function works like this:

It moves the position of the element along the x-axis, y-axis, and z-axis by the amount provided.

Move along the x-axis (horizontally)

Here's an example of using translate3d() to move an element along the x-axis (horizontally):

View Output

Move along the y-axis (vertically)

Here's an example of using translate3d() to move an element along the y-axis (vertically):

View Output

Move along the z-axis

Here's an example of using translate3d() to move an element along the z-axis. This moves the element towards or away from the viewer.

View Output

You can think of the z-axis as coming out of the screen towards the viewer. Therefore, a movement along that axis won't necessarily be apparent to the viewer unless you apply other styles that bring out the effect.

In this example, I've also included the perspective function in order to demonstrate the effect of translate3d(). The result is that the element appears to be closer to the viewer than the other (non-translated) element.

Move along all Axes

Here's an example of using translate3d() to move an element along all axes:

View Output

Negative Values

You can also provide negative values if required. This results in the element appearing further away from the user.

View Output

Official Syntax

The official syntax of the translate3d() function is as follows:

Possible Values

The translate3d() function accepts a <translation-value> value for the first two arguments, and length for the third argument. All arguments specify how much the element moves along the respective planes.

The <translation-value> is a length (e.g. 10px, 10vw, etc), and it can can also be a number without a unit identifier. In this case the number gets interpreted as "user unit". A user unit in the the initial coordinate system is equivalent to the parent environment's notion of a pixel unit.

CSS Specifications

Browser Support

The following table provided by Caniuse.com shows the level of browser support for this feature.