-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make child visible outside of overflow: hidden
#4092
Comments
Thanks for the detailed use cases. For the case where But that doesn't help with the case where you want to extend outside of a scrolling container, but still be positioned relative to an element inside that scroller. |
I love the sound of this. |
In your particular example, isn't this solved by having a wrapper around the image and adding overflow: hidden to that and you can also add border-radius to it. Like so https://jsbin.com/lewacofiji/1/edit?html,css,output ? |
+1 I run into this constantly. |
That does workaround the issue, but it feels like a hack, no? (Duplicating styles.) Also, sometimes you don't know what content will appear inside ahead of time because it's dynamic. We just need to clip everything inside except "these" elements. |
@domenic and others have begun discussing this to improve the controls/components story for this specific reason, here is the issue: whatwg/html#4633 I agree that this should live in CSS as it is effectively trying to bring the window focusing model that OSes have. As denoted in that thread I think there needs to be some research done as this is effectively trying to do |
Yeah. @tabatkins and I discussed some potential CSS properties that would make this work, but I'm hesitant to even write them up here, because I still think priority number one is research of the type outlined in whatwg/html#4633. Jumping to particular API proposals or solutions without having that grounding seems problematic to me, so I'm still really hoping to make some time to dig in to the questions listed there. |
I think a z-index type of thing that effectively pushed the element out of its container would be the way to go and very useful. For this particular use case, you can use |
Technically, CSS already has one possibility to do this: it's absolutely positioned elements whose containing block is outside the However, it would be great if we can control this explicitly! |
@SelenIT Copying your code comment here for reference:
The downside of doing this is you lose the ability to define the absolute element's size in terms of its parent, inside the |
@domenic completely agree. Added a few labels to denote that as such. @OliverJAsh yeah, that's the goal :) |
This isn't going to be useful feedback, but these suggestions probably sound terrifying to implementers. One of the reasons an OS window system can do this is because it doesn't have anything like the complexity of CSS layout. It just draws bitmaps in a particular order (and they often still fall short in some of the examples above). Take the If you stick to native controls in CSS, then maybe it will work. The native |
@grorg Thanks for the feedback, much appreciated - it's actual useful feedback because it let's me know you're freaked out to implement it :)
Interestingly enough, this is precisely how I'd summarize what I'd want it to do, it's the heuristic we need to work out (eg: this will not be another
Along with the other form control styling investigations we're doing, this is actually at the top of the list of the first things I plan to dig into. I posit that you don't need it to escape the window. But, I'll need to go add some telemetry and get end user feedback to see if that holds true. That said - I don't think we're in a position to actually propose something for this yet. As I wind down some of my other work I'll begin digging into |
It is absolutely not ever going to be allowed for arbitrary web content to escape the window. That would mean there is zero trustable UA pixels in the window; we're already at a dangerous minimum of trustability today. |
@tabatkins If you think I implied that - that was not what I meant at all. I'm saying that we need to look hard at the situation we are currently facing, with numerous top properties replacing the |
There's also a way to do it like this:
The downside of this one is that you'll have to set the initial position with the absolutely positioned parent element and be able to adjust it only with |
Maybe it's offtopic here, but, at some point, it was possible for SVG content to escape the window boundary if it was used as a custom cursor. In theory, such cursors could have |
This fails when scrolling. |
@m4heshd yeah, you need to update position via JS. |
@orangecoloured Thanks for the suggestion. I'm trying to find a solution for a Vue project that's already completed. Refactoring in large scale is not affordable at the moment. |
I just keep running into this and it's unbearable now. Feels like pulling my hair out. Here after 3 full days spent on trying to find a workaround. Nothing works in complicated use cases. Not even positioning with JS since UPDATE: |
I've run into a number of situations where the typical solution doesn't work, because the Example: The table below has It would be amazing to have a css-only solution for this kind of layout. |
@GrossDesignCo ran into this same issue. The overflow container being higher up in the DOM and a child having to be |
Indeed. The hacky workaround we had to go with is to move the tooltips to
the bottom of the DOM outside the table and position each one with
JavaScript so that it lines up with it’s respective table row. It’s pretty
ugly.
…On Fri, Oct 1, 2021 at 3:23 AM Adam Jaggard ***@***.***> wrote:
@GrossDesignCo <https://github.com/GrossDesignCo> ran into this same
issue. The overflow container being higher up in the DOM and a child having
to be position: relative in order to position a context menu relative to
that child. I got by with the position: fixed hack mentioned further up
but it has downsides. Would be great if I could just pull it out of the
visual render stack of the scrolling grandparent but still position it as
usuall against the closest positioned parent.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4092 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGGRVSDWCJ2IYMR74V2KG3UEWDYFANCNFSM4H66MKAA>
.
|
This issue led me to create a pair of custom elements that can overcome this limitaion. Here's how it works: When This exact behavior may not be what everyone in this thread is looking for but the techniques used to achieve it may be helpful to someone with the time to dissect what I've done. Example: https://i.imgur.com/XDCCDShl.jpeg |
Ran into the same issue. It would be great to have a CSS only solution. |
This saved my life: https://www.youtube.com/watch?v=jLtNh5Kl4TA I'm building a chrome extension that can't assume which parent is overflow:hidden; in the DOM. Added fixed to the div, relative to a parent, and scale(1) to the body and worked beautifully. |
For my situation I used this trick: .editor-container { |
This works for me. I changed the parent's position to static and added 'visibility: visible' to the children. |
What if the styles of the parent must be have overflow: hidden, and there is a component inside that parent, now no matter what I do of changing styles, wrapping, z-index.. etc., the component overflow will still be hidden. |
I strongly dislike the question: "is there a way to do this given the current state of our system"? A much better question might be, "what is the best experience we can give to our develops, and what changes ought we make to our system to accomplish this?" The answer to the former question is to do something clever with clip-paths. The answer to the latter is to implement what the OP is suggesting in the most direct way possible without involving clip-paths. I understand that there are some reasons why this is a very difficult engineering problem, but it's not like we're trying to go faster than the speed of light here -- there is probably a way to get this done. |
The Popover API should allow the listbox to break out of the parent element's clipping. |
Really wish there was a one-and-done CSS property for this when you want to avoid having to circumvent it with an outside modal, element or position: fixed trick like what popover api does. Would come in very handy for children rendered within an overflow: hidden; or clip-path parent - or situations where your parent is forced to use overflow: hidden; because you wanted access to resize: both; while still allowing some children to poke out (and want to avoid scroll bars). Call it breakout: breakout; & breakout: none; or something along those lines and make it apply against the closest explicit ancestor overflow declaration (Akin to the relation between position relative and position absolute). |
Apply a fixed position to the container you want to overflow and set transform: scale(1) on the parent div above the one with overflow: hidden.
Here, the parent is the div above the container. |
Suggestion
A way to force a child element to appear visible outside of a hidden overflow container.
Example use case
I have a modal element with rounded borders. Because this modal contains an image, I need to use
overflow: hidden
in order to mask the image inside of the modal element's border—so the image doesn't overflow the modal element's border.This modal element contains another child element which should be allowed to overflow this element—an input with an autocomplete list. Unfortunately however, the
overflow: hidden
prevents all children from overflowing, so the autocomplete list is clipped:Here is a reduced test case:
https://jsbin.com/cuxabik/6/edit?html,css,output
What we want:
What we have:
I am not aware of any existing CSS features which solve this problem, but it's quite a common problem to have.
The autocomplete list could exist outside of the overflow container, but then you lose the ability to define its layout in terms of its parent.
Perhaps we could instruct the child element to appear visible outside of its overflow container:
Related issues/articles
This problem has also been described here: https://css-tricks.com/popping-hidden-overflow/. (Their solution was to revert to JS for calculating layout.)
This problem is potentially related to:
The text was updated successfully, but these errors were encountered: