Reputation: 21
in MDN web docs it is mentioned that stacking context is formed in these scenarios:
will-change
value specifying any property that would create a stacking context on non-initial valuebut when I set will-change
to opacity
(non-initial value of less than 1) the stacking doesn't work as expected (blue div below red one), see this fiddle
some other scenarios works as expected like; blue div above red one (links to fiddles)
what am I doing wrong, and is there any other way to make stacking context works as expected
I'm asking because sometime I can't change the position to relative as this will affect the absolute children of that element
Upvotes: 2
Views: 138
Reputation: 947
The stacking (creation of a new layer) is actually working.
The problem is that z-index
works only for:
absolute
, relative
, fixed
, sticky
).flex
container.No matter if you set z-index: 30
, at the end it will remain at its default value, auto
.
Upvotes: 1