Stacking Context can be created with an opacity of 1 inside animation keyframe #21002
Labels
Content:CSS
Cascading Style Sheets docs
help wanted
If you know something about this topic, we would love your help!
MDN URL
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
What specific section or headline is this issue about?
The stacking context
What information was incorrect, unhelpful, or incomplete?
I ran into a problem today where there was a page that had an animation keyframe that changed the opacity from 0 to 1 that was creating a stacking context (or, at least something that behaves and looks like a stacking context). Even if you change the keyframe to use opacity from 1 to 1, it is still creating a stacking context, which is (so far as I an tell) undocumented behaviour that is reproducible on Chrome, Safari, and Firefox.
Maybe this is more of a browser bug than a documentation bug?
What did you expect to see?
Assuming the behaviour I have outlined is expected behaviour, this should be documented. If not, then someone (or I) should be reporting this issue.
Do you have any supporting links, references, or citations?
I have a proof of concept HTML page to illustrate my point.
The only difference between the left (blue) and right (red) box (apart from their position and colour) is that the red box has an animation with a keyframe that changes opacity from 1 to 1 on a parent div, while the blue one does not.
As you can see, that animation has created a stack context, causing the red box to be behind the black header.
If you try removing the animations from the
.test
css rule, the red box comes in front of the header as expected. If you then setopacity: 1
in the.test
while the animations are still removed, there is still no stacking context (as expected)If you then change that opacity to something < 1 (still with the animations commented) a new stacking context is created as expected, and the red box appears behind the black header (exactly the same as when we had the animation)
Do you have anything more you want to share?
Screenshot of the HTML I provided above rendered in chrome (unexpected stacking context created):
Same page, but with the animations removed (no stacking context, as expected):
Same page but animations removed and
opacity: 1
set (no stacking context, as expected):Same page but animations still removed, and
opacity: 0.999
is set (stacking context created, as expected):MDN metadata
Page report details
en-us/web/css/css_positioning/understanding_z_index/the_stacking_context
The text was updated successfully, but these errors were encountered: