css - Can css3 translateZ() be used instead of z-index? -
for example having 2 div's positioned absolute, 1 can put first div upon second setting first div's z-index higher second one's. can achieve such behaviour using translatez() or translate3d?
the answer now, 3 years after, can. need use transform-style: preserve-3d;
on parent, but it's possible.
.container { transform-style: preserve-3d; } .test1 { width: 500px; height: 500px; background: red; transform: translate3d(0, 0, 1px); } .test2 { width: 500px; height: 500px; background: green; left: 250px; top: 250px; position: absolute; transform: translate3d(0, 0, 0); }
<div class="container"> <div class="test1"> test </div> <div class="test2"> test #2 </div> </div>
Comments
Post a Comment