what is the difference between the z-index
and transform:translateZ();
in css
Asked
Active
Viewed 2,261 times
-2

dippas
- 58,591
- 15
- 114
- 126

Ayush Gupta
- 98
- 8
2 Answers
2
The z-index
-property is supposed to be a measure of stacking positioned elements while translateZ()
is supposed to be animated and transitioned to move objects in the 3d-space.
They can be used interchangeably in some scenarios which you can learn more about here.

leonheess
- 16,068
- 14
- 77
- 112
1
The z-index
property allows you to set the order of the stack where any greater number assigned to it will just bring it in front of the other element whereas transform:transitionz()
will actually decide the distance by which the element will be farther from another elements on z-axis.

Kunal Raut
- 2,495
- 2
- 9
- 25