Skip to main content
100%

stacking context

✓ Published0🌍 Public
EEE2dev
Last edited Mar 3, 2018
Created on Feb 10, 2018

This example demonstrates how CSS stacking contexts determine the paint order of overlapping positioned elements. Three colored squares—red, green, and blue—are absolutely positioned within separate parent divs, yet their visual layering follows the order of the divs in the DOM. The code uses plain CSS positioning (top/left offsets) and background colors, with no JavaScript or external libraries. A commented-out universal selector block shows a debugging technique for visualizing layout boxes, but the active CSS keeps the example minimal. The illustration clarifies that without explicit z-index, later siblings paint above earlier ones, as seen in the stacked arrangement.

AI-generated description

Built with blockbuilder.org

Example from the excellent article https://philipwalton.com/articles/what-no-one-told-you-about-z-index/

To look at layouts, do: * { background: #000 !important; color: #0f0 !important; outline: solid #f00 1px !important; }

mit Licensed

Similar vizzes