Thanks to visit codestin.com
Credit goes to www.cssportal.com

CSS Portal

translate3d() CSS Function

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The translate3d() CSS function is a powerful method used to move an element in three-dimensional space along the X, Y, and Z axes. Unlike its 2D counterpart translate(), translate3d() allows you to specify movement in the Z direction, giving elements a sense of depth when combined with transform properties and perspective settings. This function can be particularly useful for creating animations, transitions, and interactive UI effects that require a more immersive visual experience.

When using translate3d(), you provide three values: the first for horizontal movement (X-axis), the second for vertical movement (Y-axis), and the third for depth (Z-axis). Positive values move the element forward along the axis, while negative values move it backward. The units can be pixels, percentages, or other CSS length units. Movement along the Z-axis is most effective when combined with perspective, which allows the browser to render the element with realistic depth.

For example, applying translate3d(50px, 100px, 30px) to a div would move it 50 pixels to the right, 100 pixels down, and 30 pixels toward the viewer. Animations using translate3d() are often more performant than animating left or top properties, because they leverage the GPU for smoother transitions.

Another common use case is combining translate3d() with rotate3d() or scale3d() to create complex 3D transformations, such as flipping cards or simulating a 3D carousel. This makes it a versatile tool for modern web design where depth and motion are desired.

Example usage:

.card {
  transform: translate3d(20px, 40px, 50px);
  transition: transform 0.5s ease-in-out;
}

This would smoothly move the element along all three axes over half a second when the transformation is applied.

Syntax

transform: translate3d( tx, ty, tz);

Values

  • txHorizontal shift. A positive value shifts to the right, a negative value to the left.
  • tyVertical shift. A positive value moves up, a negative value down.
  • tzA positive value moves the element towards the viewer, and a negative value farther away.
Any length units accepted in CSS are accepted as values ​​- for example, pixels (px), inches (in), points (pt), etc. A positive value shifts forward, a negative one backwards. A value of 0 does not change the position of the element.

Example

<div class="scene">
<div class="card">
3D Translate
</div>
</div>
/* The parent container provides the 3D context */
.scene {
width: 200px;
height: 200px;
perspective: 600px;
margin: 50px;
}

/* The element we are moving */
.card {
width: 100%;
height: 100%;
background-color: #3498db;
color: white;
display: flex;
align-items: center;
justify-content: center;
font-family: sans-serif;
font-weight: bold;
border-radius: 10px;
transition: transform 0.5s ease; /* Smooths the movement */
}

/* When hovering over the scene, move the card:
X: 50px (right)
Y: 20px (down)
Z: 100px (toward the user)
*/
.scene:hover .card {
transform: translate3d(50px, 20px, 100px);
background-color: #2ecc71;
}

Browser Support

The following information will show you the current browser support for the CSS translate3d() function. Hover over a browser icon to see the version that first introduced support for this CSS function.

This function is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!