This content originally appeared on CSS-Tricks and was authored by Chris Coyier
In “What the heck, z-index??,” Josh Comeau makes the analogy of layer groups in design software like Photoshop or Figma to stacking contexts in CSS. If you’ve got an element in a layer group A in Photoshop that is below layer group B, there is nothing you can do to push a child of A on top of anything in B, aside from moving the whole layer group A above B, or getting rid of the groupings.

Here’s a reduced case:
There is no z-index
value that is going to get “Big Thing” on top of the tan <main>
element there. But as Josh notes in the article, there are a variety of solutions, such as preventing a stacking context from triggering unnecessarily, or doing a little DOM shuffling to make things work. Like in the example above, “Big Thing” doesn’t need to be a child of the header — and if it wasn’t, the stacking context wouldn’t be as relevant.
If you’re a fan of your tools helping you diagnose this kind of thing, read to the bottom of Josh’s article for a few interesting ones.
Direct Link to Article — Permalink
The post It’s always the stacking context. appeared first on CSS-Tricks.
You can support CSS-Tricks by being an MVP Supporter.
This content originally appeared on CSS-Tricks and was authored by Chris Coyier

Chris Coyier | Sciencx (2021-03-22T19:27:56+00:00) It’s always the stacking context.. Retrieved from https://www.scien.cx/2021/03/22/its-always-the-stacking-context/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.