-
Notifications
You must be signed in to change notification settings - Fork 764
Open
Labels
Description
Problem/motivation
Currently, if an element is made into a scroll container (e.g. using overflow: auto or overflow: hidden), then nothing inside it can "escape" out.
It is often desirable for some parts to be able to escape. Consider three examples:
box-shadowoften needs to protrude out of the container. Very common.position: absoluteis often used to make elements protrude out or be anchored near one of the edges. One use case is nested scrollable sub menus, demonstrated in the css-tricks article "Popping out of hidden overflow".transformcan be used to displace an element out of the container. Used in combination withdisplay: grid(e.g.place-self: end), this is a great way to place decorative or functional elements near the corners of the containers.
In all of these examples, the element gets clipped if it tries to escape the scroll container.
Ideas
There could be a simple way to make an element not be constrained by the scroll container.
.scroll-container {
overflow: auto;
.escape {
overflow-escape: x; /* or y or both */
}
}@daviddarnes suggested a more powerful idea, where an element could specify which scroll container it wants to (not) be constrained by.
.scroll-container {
overflow: auto;
.escape {
overflow-container: none;
}
}.scroll-container {
overflow: auto;
container-name: one;
contain: overflow;
.another-scroll-container {
overflow: auto;
container-name: two;
.escape {
overflow-container: one;
}
}
}Another idea that might solve some use cases would be to allow individual elements to control their own version of overflow-clip-margin.
.escape {
/* will be clipped if it goes more than 20px outside the scroll container */
overflow-escape-margin: 20px;
}yisibl, justindgm, heyyfurqan, SammyM, amatveiakin and 13 moredaviddarnes, Senne, lukebennett88, JPrisk, tylersticka and 12 more