Skip to content

[css-grid] Should calc(1fr) be invalid? #6989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
LeaVerou opened this issue Jan 26, 2022 · 5 comments
Closed

[css-grid] Should calc(1fr) be invalid? #6989

LeaVerou opened this issue Jan 26, 2022 · 5 comments
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-grid-1 css-grid-2 Subgrid; Current Work css-grid-3 Masonry Layout

Comments

@LeaVerou
Copy link
Member

LeaVerou commented Jan 26, 2022

Testcase: https://codepen.io/leaverou/pen/dyZPoRz

Right now, all browsers seem to be treating any fr in calc() as invalid, even calc(1fr), which is unfortunate, since using calc() to calculate the ratio between grid columns is quite useful. E.g. my use case went something like:

grid-template-columns: calc(1fr * var(--divider-ratio, .5)) calc(1fr * (1 - var(--divider-ratio, .5)));

Is this per spec, or is it just a misunderstanding of this note by implementors?

@LeaVerou LeaVerou added css-grid-1 css-grid-2 Subgrid; Current Work css-grid-3 Masonry Layout labels Jan 26, 2022
@LeaVerou
Copy link
Member Author

ping @fantasai

@tabatkins
Copy link
Member

Definitely a bug; fr units should be math'able just fine. That note is, indeed, just observing that fr is not a <length> so calc(1px + 1fr) is invalid, but calc(1fr / 3) should be just fine.

@tabatkins tabatkins added the Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. label Jan 26, 2022
@tabatkins
Copy link
Member

(Closing because this has a straightforward answer; please file bugs!)

@Loirooriol
Copy link
Contributor

https://drafts.csswg.org/css-values/#math covers <flex>.

[BTW, your test should use section ~ section since they are not adjacent. But yeah, seems unsupported]

@kizu
Copy link
Member

kizu commented Nov 23, 2023

Just in case, cross-linking browser bugs for this:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-grid-1 css-grid-2 Subgrid; Current Work css-grid-3 Masonry Layout
Projects
None yet
Development

No branches or pull requests

4 participants