4 ms·
Yes, set position:relative on a parent element, then set position:absolute with a z-index on the child element. The z-index will be relative to the parent, not
by fleddr 4y ago
Yes, set position:relative on a parent element, then set position:absolute with a z-index on the child element. The z-index will be relative to the parent, not to the document.
- robocat 4y agoOne of the wonders of CSS (well, browsers) is that you can devote a decade to learning all the various details, and still not know something so fundamental. Thank you. I don’t want to believe I could miss that, but I have been humbled enough times to be doubtful about my beliefs.
- myfonj 4y ago"Stacking context" creation is one of those concepts that many coders skip while learning as "intuitive enough not to dive deeper", and then stare in disbelief on list of properties that affects this, as pointed out in https://news.ycombinator.com/item?id=32600047 https://news.ycombinator.com/item?id=32600047 . Who would have thought that `will-change: mask-image` would have similar effect similar to `position: relative`?
- marcosdumay 4y agoSomebody posted the documentation of stack isolation in another thread. If you want exactly that, and only that, my conclusion is that the best way is to use `isolation: isolate`.