I’m trying to visualize an animation. I had a strange problem that absolute positioning doesn’t make my div the top one.
Simply I have, a container and a series of div and a single child for each.
<div id="outer">
<div class="inner1"> <!-- this is relative -->
<div class="inner2"></div> <!-- this is absolute with z-index 1000 (1)-->
</div>
<div class="inner1"> <!-- this is relative (2) -->
<div class="inner2"></div> <!-- this is absolute -->
</div>
</div>
Why is (2) under the (1)
Please check the fiddle to understand my problem.
As far as I can see from your fiddle, you don’t actually have
.inner2absolutely positioned, and you are currently moving it right using a left-margin.If you add
position: absoluteto the CSS rules of.inner2this seems to fix the problem.You might also be interested in reading this article about CSS transition/transform performance (I noticed your using CSS to transition the
.inner2elements)