Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
Autumn in Year 5 - @210.09
Two Stars Random | Recent Posts | Guild Recents
News: There's a great big indie web tomorrow! :smile: Guild Events: weekly zine theme 12: television

+  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 712 times)
dogbrain
Full 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: Spring in Year 5 @900 » 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


Artifact Swap: Dig Creature
Dan Q
Hero Member ⚓︎
*****
View Profile WWWArt


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

Guild Memberships:
Artifacts:
Dan Q Cruisin'I DIDN'T meet Dan Q on Melonland!Visited on Melon's 10th Anniversary!
« Reply #1 on: Spring in Year 5 @316 » 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: PolyamorousI met Dan Q on Melonland!Joined 2025!
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
@000 Melon
Land
Editor Recent Edits Tenement Arcade Random Link Land → Forum Art Hub Chat Webring Want to Login or Join ? Web Craft Guide Graphic Catalogue Wiki Newsletters Image Stream
Passport Sites Asatte Add your site?
Zap!
Minecraft: Online
Join: craft.melonking.net