Skip to content

[css-position][css-anchor-position] Splitting Scrollable Containing Blocks #12607

@fantasai

Description

@fantasai

When reviewing some incorrect testcases about the interaction of anchor positioning and scroll containers, and also the considering #10861, Tab and I concluded that there are multiple behaviors that are needed when attaching an abspos to a scrollable containing block, and we should introduce a switch. (Ian and Tab also came to this conclusion in a different discussion.)

The three possible behaviors for a scrollable containing block are:

  • attach to the scrollport, do not scroll with the content ("outside" the scroller)
  • attach to the "initial containing block" (coinciding with the scrollport at the initial scroll position), scroll with the content ("inside" the scroller)
  • attach to the "scrollable containing block" (roughly the scrollable overflow area), scroll with the content

Our proposal is to split positioning into three controls:

  • position-type: static | relative | sticky | absolute
  • position-attachment: auto | local | fixed | scroll
  • position-container: nearest | farthest | <custom-ident>

The position-container property was introduced in #9868

The position-attachment values are as follows:

position would accept <'position-type'> || <'position-attachment'> || <'position-container'> and resolve as follows (setting omitted values to initial):

  • static -> position-type: static
  • sticky -> position-type: sticky
  • relative -> position-type: relative
  • absolute -> position-type: absolute; position-container: nearest; position-attachment: auto
  • fixed -> position-type: absolute; position-container: farthest; position-attachment: fixed

For compat reasons, position-container: farthest; position-attachment: fixed may need to convert to local attachment if intercepted by a CB before the root (but it would be nice if we could not do this).

Doing this nicely will require shorthandifying position, though, so that's a topic we really do need to figure out. Working around it would be... awful.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Thursday Morning

    Status

    Agenda+

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions