Skip to content

[css-anchor-position] Make anchor-center work without position-anchor #10366

@yisibl

Description

@yisibl
  1. Open
data:text/html;charset=UTF-8, <style>
.anchor { anchor-name: --foo; width: 100px; height: 50px; display: block; margin: 30px auto;} 
.anchored{position: absolute; left: anchor(--foo 50%); top: anchor(--foo bottom); 
justify-self: anchor-center; background: green; padding: .5em 2em;}</style>
<button class="anchor">anchor</button>
<div class="anchored">anchored</div>
  1. The green element is not horizontally centered with respect to the button.

We must add position-anchor: --foo for anchor-center to take effect. This is often confusing to the user because <anchor-element> is already defined on the left.

Can we change the status quo?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions