这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@jamesnw
Copy link
Contributor

@jamesnw jamesnw commented Apr 4, 2025

Description

https://drafts.csswg.org/css-anchor-position-1/#anchor-size-fn

Spec changed in w3c/csswg-drafts#9827 to allow anchor-size on all properties that are allowed in @position-try blocks. This includes some nonsensical ones like align-self, which don't take lengths. I went with the "technically correct" tact of allowing anchor size to be used on those, but I alternatively could define a subset of the @position-try declarations that actually accept lengths.

Related Issue(s)

Fixes #288

Steps to test/reproduce

https://deploy-preview-309--anchor-polyfill.netlify.app/#anchor-size-extended

@jamesnw jamesnw requested a review from jgerigmeyer April 4, 2025 19:11
@netlify
Copy link

netlify bot commented Apr 4, 2025

Deploy Preview for anchor-polyfill ready!

Name Link
🔨 Latest commit 0d354f5
🔍 Latest deploy log https://app.netlify.com/sites/anchor-polyfill/deploys/67f41d2c23b4250008d05401
😎 Deploy Preview https://deploy-preview-309--anchor-polyfill.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Apr 4, 2025

Deploy Preview for anchor-position-wpt canceled.

Name Link
🔨 Latest commit 0d354f5
🔍 Latest deploy log https://app.netlify.com/sites/anchor-position-wpt/deploys/67f41d2c155ed400080de466

Copy link
Member

@jgerigmeyer jgerigmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works well!

I alternatively could define a subset of the @position-try declarations that actually accept lengths.

My reading of the spec is actually that anchor-size only accepts a subset of the valid @position-try declarations that do accept lengths:

It’s being used in a sizing property, an inset property, or a margin property on an absolutely positioned box. (These are the accepted @position-try properties that allow lengths.)

So I'd recommend we split ACCEPTED_POSITION_TRY_PROPERTIES from ACCEPTED_ANCHOR_SIZE_PROPERTIES.

@@ -0,0 +1,12 @@
#my-anchor-anchor-size-extended {
anchor-name: --my-anchor-size-extended;
resize: both;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fun! I approve 🤓

@jamesnw jamesnw requested a review from jgerigmeyer April 7, 2025 18:45
@jamesnw jamesnw merged commit 9400067 into main Apr 7, 2025
14 checks passed
@jamesnw jamesnw deleted the anchor-size-margin-inset branch April 7, 2025 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support anchor-size() on insets and margins

3 participants