translateZ() CSS Function
Description
The translateZ() CSS function is a 3D transformation function that moves an element along the z-axis, which is perpendicular to the screen. Unlike 2D transformations like translateX() or translateY(), translateZ() creates the illusion of depth by shifting elements closer to or farther from the viewer. Positive values move the element toward the user, while negative values move it away from the user.
This function is often used in combination with the transform property and can enhance visual effects in 3D layouts, such as card flips, rotating cubes, or parallax scrolling. Using translateZ() effectively usually requires a parent element with perspective applied to give the movement along the z-axis a realistic depth appearance.
For example, consider a 3D card effect:
<div class="card-container">
<div class="card">Front</div>
</div>
.card-container {
perspective: 800px;
}
.card {
width: 200px;
height: 300px;
background-color: #4caf50;
transform: translateZ(50px);
transition: transform 0.5s;
}
In this example, the card appears closer to the viewer by 50 pixels along the z-axis. Adjusting the value of translateZ() can create dramatic depth effects when combined with rotations using rotateY() or rotateX().
Because translateZ() only affects the visual position in 3D space, it does not change the element's layout in the document flow, similar to how transform works in general.
Syntax
transform: translate(tz);
Values
- tzA <length> representing the z-component of the translating vector. A positive value moves the element towards the viewer, and a negative value farther away.
Example
Browser Support
The following information will show you the current browser support for the CSS translateZ() 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
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
