w3c / w3c/csswg-drafts

[css-anchor-position-1] Retrieving not just position/dimensions of anchors, but other properties as well

Open
#8,587 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

css-anchor-position-2
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

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:

Ok, this could be a bit far-fetched, and mostly inspired by the inherit() proposed in this issue — https://github.com/w3c/csswg-drafts/issues/2864, but I just need to mention this :)

What if, for absolutely positioned elements, if we could use a certain element as an anchor, we could then get not just its dimensions and position, but also just any other properties we'd want?

One use-case I thought of — adjusting the color/theme of an absolutely-positioned element based on other elements — if we're attaching an element to a bright target, we draw it with a light mode, if it is attached to a dark element — with a dark mode, and so on.

If we're using multiple elements for the base, we could draw a gradient using the backgrounds of multiple elements as different stops.

Dropdowns could adapt to the target's fonts, elements could adapt to other elements' opacity, visibility etc.

Of course, there'd be some limitations, especially if we'd allow getting the value of CSS variables, but for getting some regular properties via something like anchor-property(background-color) or whatever this maybe could work?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CSS Anchor Positioning Level 1 specification and the related inherit() issue linked in the report. Review the proposed anchor-property() behavior and its examples, then determine whether retrieving properties belongs in this specification and what limitations would be required. Done means a decided, scoped proposal or an explicit resolution for the request.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.