Why does a transform or opacity declaration create a new stacking context?
Quick answer
A transform or opacity below 1 can create a stacking context: a self-contained group whose descendants are stacked internally, while the group is handled as one unit by its parent context. So a child’s large z-index cannot independently jump above an outside element that stacks above the child’s parent context. Compare the parent contexts first; changing the child’s z-index alone may not help. [S1]
The question, the details, the next step.
A practical checklist
A few more useful answers
Does a very large z-index always put an element on top?
No. A child is stacked within its context; it cannot independently outrank an outside element that stacks above its parent context. [S1]
Which two declarations are relevant to this problem?
The cited reference lists transform and opacity below 1 as stacking-context creators. [S1] This guide does not list every possible stacking-context trigger.
Should I remove the transform or opacity declaration?
Not automatically. First confirm which ancestor creates the context and whether changing the relationship between parent contexts or the element structure better fits the intended layout.
Sources
References used for this guide.
- [S1] Stacking context — CSS | MDN developer.mozilla.org · Checked
