CSS· Stackingz-index
Controls which overlapping element sits in front. Higher numbers win within the same stacking context.
.mushroom { position: relative; }
.stem { position: absolute; z-index: 1; }
.cap { position: absolute; z-index: 2; }
Note to selfWorks on positioned elements and flex/grid items. If 9999 won’t help, check the parents before adding another nine.
CSS· StackingStacking context
A group whose layers stay together. Children can move in front of each other, but can’t escape their group’s position behind another group.
.back-group { position: relative; z-index: 1; }
.front-group { position: relative; z-index: 2; }
.back-group .mushroom { position: absolute; z-index: 9999; }
Note to selfThink of two folders of layers. You can rearrange layers inside each folder, but if folder A sits behind folder B, everything inside A stays behind B.