Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

CSS Tutorial

CSS HOME CSS Introduction CSS Syntax CSS Selectors CSS How To CSS Comments CSS Errors CSS Colors CSS Backgrounds CSS Borders CSS Margins CSS Padding CSS Height / Width CSS Box Model CSS Outline CSS Text CSS Fonts CSS Icons CSS Links CSS Lists CSS Tables CSS Display CSS Max-width CSS Position CSS Position Offsets CSS Z-index CSS Overflow CSS Float CSS Inline-block CSS Align CSS Combinators CSS Pseudo-classes CSS Pseudo-elements CSS Opacity CSS Navigation Bars CSS Dropdowns CSS Image Gallery CSS Image Sprites CSS Attribute Selectors CSS Forms CSS Counters CSS Units CSS Inheritance CSS Specificity CSS !important CSS Math Functions CSS Optimization CSS Accessibility CSS Website Layout

CSS Advanced

CSS Rounded Corners CSS Border Images CSS Backgrounds CSS Colors CSS Gradients CSS Shadows CSS Text Effects CSS Custom Fonts CSS 2D Transforms CSS 3D Transforms CSS Transitions CSS Animations CSS Tooltips CSS Image Styling CSS Image Modal CSS Image Centering CSS Image Filters CSS Image Shapes CSS object-fit CSS object-position CSS Masking CSS Buttons CSS Pagination CSS Multiple Columns CSS User Interface CSS Variables CSS @property CSS Box Sizing CSS Functions CSS Media Queries

CSS Flexbox

Flexbox Intro Flex Container Flex Items Flex Responsive

CSS Grid

Grid Intro Grid Container Grid Items Grid 12-column Layout CSS @supports

CSS Responsive

RWD Intro RWD Viewport RWD Grid View RWD Media Queries RWD Images RWD Videos RWD Frameworks RWD Templates

CSS Cert

CSS Certificate

CSS SASS

SASS Tutorial

CSS Examples

CSS Templates CSS Examples CSS Editor CSS Snippets CSS Quiz CSS Exercises CSS Code Challenges CSS Website CSS Syllabus CSS Study Plan CSS Interview Prep

CSS References

CSS Reference CSS Selectors CSS Combinators CSS Pseudo-classes CSS Pseudo-elements CSS At-rules CSS Functions CSS Reference Aural CSS Web Safe Fonts CSS Animatable CSS Units CSS PX-EM Converter CSS Colors CSS Color Values CSS Default Values CSS Browser Support

CSS 3D Transforms


Share

CSS 3D Transforms

The CSS transform property is also used to apply a 3D transformation to an element.

To activate a 3D space, the element needs perspective. The perspective defines the distance between the user's viewpoint and the element. Without perspective, any 3D transforms will look flat and two-dimensional.

You will learn more about Perspective in the next chapter. 


Core 3D Transforms Functions

Within the transform property it is common to use the following 3D functions:


The CSS rotateX() Function

The rotateX() function rotates an element around its x-axis at a given degree.

This means that it tilts an element forward or backward:

rotateX(45deg)

Example

.box {
 transform: rotateX(45deg);
}
Try it Yourself »


The CSS rotateY() Function

The rotateY() function rotates an element around its y-axis at a given degree.

This means that it swivels an element left or right (like a swinging door):

rotateY(45deg)

Example

.box {
 transform: rotateY(45deg);
}
Try it Yourself »

The CSS rotateZ() Function

The rotateZ() function rotates an element around its z-axis at a given degree.

This means that it spins the element flat on the screen (at a given degree):

rotateZ(45deg)

Example

.box {
 transform: rotateZ(45deg);
}
Try it Yourself »

The CSS translateZ() Function

The translateZ() function repositions an element along the z-axis in 3D space.

This means that it moves the element closer to or farther away from the viewer.

A positive value moves the element closer to the viewer. A negative value moves the element farther away from the viewer:

translateZ(-100px)

Example

.box {
 transform: translateZ(-100px);
}
Try it Yourself »


CSS Transform Properties

The following table lists all the 3D transform properties:

Property Description
transform Applies a 2D or 3D transformation to an element
transform-origin Allows you to change the position on transformed elements
transform-style Specifies how nested elements are rendered in 3D space
perspective Defines the distance between the user's viewpoint and the element
perspective-origin Specifies the bottom position of 3D elements
backface-visibility Defines whether or not an element should be visible when not facing the screen

Core 3D Transform Functions

Function Description
rotateX() Rotates an element around its horizontal axis (x-axis)
rotateY() Rotates an element around its vertical axis (y-axis)
rotateZ() Rotates an element around the depth axis (z-axis)
perspective() Defines the distance between the user's viewpoint and the element
translateZ() Moves an element closer or further
scaleZ() Scales the element's depth along the z-axis

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.