-
Notifications
You must be signed in to change notification settings - Fork 194
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
Can popovers be relatively positionable without anchor positioning? #723
Comments
I think the top layer lays out after the main layer by definition, so if your request is that the popover layout at the same time as the button in the main window, that seems like something that would be difficult to achieve. Anchor positioning is the only way with CSS I think to position an element in the top layer based on the computed position of another element in the main layer. JS that reads the computed positions of elements would be the only way, obviously that comes with downsides. |
Thanks, Tom! So is it fair to say the reason my top layer element is positioned in the center simply, because that was considered a sensible default, given there is no knowledge of elements in the main layer? Looking at when I would use a modal
|
|
I believe this was discussed in #561. I think positioning center is maybe more defaulty than picking a corner of the viewport. But in any case, it's in the spec now so it may be too late: https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3. |
Just to echo a few of the comments, relative positioning isn't possible for |
Thanks, that all makes sense. I somewhat worry that _ I guess I was dreaming/hoping about some kind of default positioning because browsers do it for listboxes of (Of course there may also be popovers that aren't centered or relative to a triggerer; am thinking meganavs that are full width of viewport/some container) In any case, thanks for the explanations all! |
Agreed, but as you said, impossible. The only way to position popovers relative to something else is via anchor positioning.
Right - in the |
Ok, got it! Will close this issue as my question now has a clear answer. Thanks again! |
@mfreed7 Is that in a spec yet somewhere? I looked in openui/whatwg/csswg, but couldn't find this. |
@josepharhar is there an HTML PR for this? I thought there was, but I can't seem to find it. The CSS side of the spec is located here. |
I have a PR to add the anchor attribute here, which should do the implicit anchor thing: whatwg/html#9144 |
When I build a popover without
[popover]
, I would often want to position relative to the button that opens it.One way to do that is to put the popover and its opener in a relatively positioned element:
When I use
popover
, the popover is in the top layer and positioned in the center, and my absolute positioning would happen relative to that center:I could position my popover relatively with anchor positioning, but I wonder:
(See my Codepen in a popover supporting browser)
The text was updated successfully, but these errors were encountered: