Skip to content

Added CSS translateZ() transform function documentation #7466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
Title: 'translateZ()'
Description: 'Moves an element along the Z-axis in 3D space.'
Subjects:
- 'Web Development'
- 'Web Design'
Tags:
- 'Functions'
- 'Positioning'
CatalogContent:
- 'learn-css'
- 'paths/front-end-engineer-career-path'
- 'paths/full-stack-engineer-career-path'
---

The **`translateZ()`** function moves an element along the Z-axis in 3D space, creating depth by moving the element closer to or farther from the viewer.

## Syntax

```pseudo
transform: translateZ(<value>);
```

The required `<value>` can be one of the following:

- Length value: `100px`, `1.5em`

**Note**: Percentage values are not allowed for `translateZ()` since the Z-axis does not have an inherent size reference like width or height.

A positive value moves the element closer to the viewer along the Z-axis, while a negative value moves the element farther away from the viewer.

## Example 1

In the example below, an element with a `.box` class is moved `50px` closer to the viewer:

```css
.box {
transform: translateZ(50px);
}
```

## Example 2

In this example, the element is moved away from the viewer by `-1.5em`:

```css
.box {
transform: translateZ(-1.5em);
}
```