Skip to content
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

[css-anchor-1] How it should work with position: fixed? #8583

Closed
kizu opened this issue Mar 15, 2023 · 4 comments
Closed

[css-anchor-1] How it should work with position: fixed? #8583

kizu opened this issue Mar 15, 2023 · 4 comments
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-anchor-position-1

Comments

@kizu
Copy link
Member

kizu commented Mar 15, 2023

Disclaimer and additional links

I'm submitting my feedback following my experiments with the current implementation of anchor positioning in Chrome Canary.

I wrote an article about my experiments, but decided to fill most of my feedback as separate issues here.

A quick summary of related links:

I saw the position: fixed mentioned a few places in the spec examples:

But outside of them, it is not mentioned anywhere in the spec.

Should the spec define how it should be handled?

I did not yet do almost any experiments with anchors and fixed positioning, would update this issue when would do — but would be awesome to hear what would be the intended behavior.

@kizu
Copy link
Member Author

kizu commented Mar 15, 2023

In the discussion of #8588 (and some tests inside of it) it seems that the intent of the position: fixed is to promote the element to the root layer, allowing for it to be attached to basically any elements as if it was not constrained by its parents with defined position etc.

@tabatkins
Copy link
Member

There's not really anything to mention, is the thing. The spec just cares about containing blocks and their relationships, and fixpos is just as well-defined in this regard as abspos is. (Note that the term "absolutely positioned", used a lot in the spec, refers to both abspos and fixpos elements, if you click thru the link to its definition.)

The big useful thing is that, since fixpos elements are laid out after pretty much the entire rest of the page, the conditions for what is an acceptable anchor are pretty trivially satisfied, so you can anchor it to pretty much anything. (Except another fixpos.)

@tabatkins tabatkins added Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-anchor-position-1 labels Mar 15, 2023
@kizu
Copy link
Member Author

kizu commented Mar 15, 2023

The big useful thing is that, since fixpos elements are laid out after pretty much the entire rest of the page, the conditions for what is an acceptable anchor are pretty trivially satisfied, so you can anchor it to pretty much anything. (Except another fixpos.)

I would say that this can be a very helpful thing to mention, maybe as a note or something in the spec — could help people who are learning about the feature to understand it better, and can be a useful example, maybe somewhere around the “acceptance criteria” which are currently very dense and can be hard to wrap your head around, as it requires you to get the meaning of all the terms that are used there. Having an example with the fixed position which can “escape” those limitations in some way could be maybe a nice way to present it?

I mean, I see how when going through all the linked terms it is possible to get the whole picture, but I'm just a fan of having useful parts be explicit, and I feel like this is something that could be worth repeating/mentioning.

@o-t-w
Copy link

o-t-w commented Jun 18, 2023

Should it be possible to position a fixed-position element in one direction by referencing the viewport but in the other direction using anchor positioning? It doesn't work in Chrome Canary at the moment but it would be useful e.g.:

.anchored {
  position: fixed;
  left: anchor(right);
  top: 0;
}

Look at the Shift example on the Floating UI JavaScript library homepage for a look at the sort of thing I mean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-anchor-position-1
3 participants