Skip to content

[css-anchor-position]: Question: Why is anchor-size() only valid in a sizing property? #9827

@coderfin

Description

@coderfin

Can you help me understand why the anchor-size() function is limited to being used in a sizing property? It would be useful outside of these properties.

https://www.w3.org/TR/css-anchor-position-1/#anchor-size-valid
https://github.com/web-platform-tests/wpt/blob/master/css/css-anchor-position/anchor-size-parse-invalid.html#L10C4-L10C55

I have a use case where I don't know the height or width of the Anchor but I would like to apply a clip-path to the Target that basically creates a notch in Target.

  --anchor-height: anchor-size(--anchor height);
  --anchor-width: anchor-size(--anchor width);
  
  clip-path: polygon(
    0 0,
    0 100%,
    calc(50% - var(--anchor-width) / 2) 100%,
    calc(50% - var(--anchor-width) / 2) var(--anchor-height),
    calc(50% + var(--anchor-width) / 2) var(--anchor-height),
    calc(50% + var(--anchor-width) / 2) 100%,
    100% 100%,
    100% 0
  );

desired-output

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Tuesday morning

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions