Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
May 20, 2026 - @490.83 (what is this?)
Activity rating: Four Stars Posts & Arts: 86/1k.beats Random | Recent Posts | Guild Recents
News: inconvenience is counterculture :eyes: Guild Events: Spring Themed Projects

+  MelonLand Forum
|-+  Life & The Web
| |-+  ✁ ∙ Web Crafting
| | |-+  TIL z-index stacking contexts are relative...


« previous next »
Pages: [1] Print Embed
Author Topic: TIL z-index stacking contexts are relative...  (Read 350 times)
dogbrain
Jr. Member ⚓︎
**
View Profile WWWArt


melting down army guys to make green tea
⛺︎ My Room
StatusCafe: robdog
iMood: robdog
RSS: RSS

Guild Memberships:
Artifacts:
Joined 2026!
« on: May 13, 2026 @900.07 » Embed

...as opposed to global, like i thought they were this entire time until now!!!  :skull:

i was fuming over not being able to position one rotated div in front of another (despite setting the z-index of the former to a stupidly high number) so i did some light googling and discovered that, apparently, z-indexes aren't global for the whole document; rather, new stacking contexts are created if you have any number of seemingly unrelated attributes on an element, and those exist in their very own 'bubbles'. in my case, it was because the div in question was rotated with transform  :drat:

i found this medium article that was helpful in explaining how this happens, but not why it happens. if anyone knows, i'm curious what about the transform property places elements in their own stacking contexts? is there a practical reason for it?? it seems weird to me that by simply applying a cosmetic change like rotation, it triggers its own stacking context o_o but i'm probably missing something!
Logged

it/he
https://files.catbox.moe/0fmlx1.gif https://file.garden/aJ42hERaRB8KTsjG/IMG_0702.gif
time is flying like an arrow, and the clock hands go so fast they make the wind blow, and it makes the pages of the calendar go flying out the window one by one
https://file.garden/aJ42hERaRB8KTsjG/IMG_1434.gif

Dan Q
Hero Member ⚓︎
*****
View Profile WWWArt


I have no idea what I am doing
⛺︎ My Room
RSS: RSS

Guild Memberships:
« Reply #1 on: May 14, 2026 @316.15 » Embed

The simple answer is, I think... it just is.

The slightly-less-simple answer is probably... that some transformations are effectively equivalent to relative re-positioning. Which necessitates a new stacking context. So declaring in the spec that it does so could potentially allows some browser engines to short-cut their positioning engines.

That'd be my guess.
Logged

https://danq.me/_q26t/badges/dan-q-88x31-lighter.gif https://danq.me/_q26t/badges/dan-q-88x31-peekaboo-scroller.gif https://beige-buttons.danq.dev/beige-buttons-88x31.gif https://embed-html.danq.dev/embed-html-88x31.gif

Artifact Swap: I met Dan Q on Melonland!Polyamorousradio polyBouncy Egg!Rainbow ConnectionpawJoined 2025!Lurby
Pages: [1] Print Embed 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | Send Feedback | Supporters ♥ Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi
MelonLand @000

Want to Login or Join ?

Minecraft: Online
Join: craft.melonking.net