-4

what is the difference between the z-index and transform:translateZ(); in css

dippas
  • 52,735
  • 15
  • 110
  • 120

2 Answers2

1

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
  • 10,362
  • 9
  • 56
  • 89
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,349
  • 2
  • 8
  • 25