Skip to content

[css-grid] fit-content with indefinite percentage #3585

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
Loirooriol opened this issue Feb 1, 2019 · 5 comments
Closed

[css-grid] fit-content with indefinite percentage #3585

Loirooriol opened this issue Feb 1, 2019 · 5 comments
Labels
Closed Accepted as Editorial Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-grid-1 Tracked in DoC

Comments

@Loirooriol
Copy link
Contributor

Loirooriol commented Feb 1, 2019

According to https://drafts.csswg.org/css-grid/#valdef-grid-template-columns-length-percentage,

If the size of the grid container depends on the size of its tracks, then the <percentage> must be treated as auto, for the purpose of calculating the intrinsic sizes of the grid container and then resolve against that resulting grid container size for the purpose of laying out the grid and its items.

But what if the indefinite percentage is inside fit-content()? https://drafts.csswg.org/css-grid/#valdef-grid-template-columns-fit-content doesn't explain this explicitly, and it can't just be treated as auto like in <length-percentage> because fit-content(auto) is not valid syntax.

I guess it should be treated as a normal minmax(auto, max-content), without the special fit-content behavior? That would match this fit-content description:

This is essentially calculated as the smaller of minmax(auto, max-content) and minmax(auto, limit).

@fantasai
Copy link
Collaborator

fantasai commented Feb 1, 2019

Yes. The invalidity of fit-content(auto) is because such a syntax would be meaningless: it's roughly equivalent to just auto. I don't think the spec is inconsistent or unclear about what happens here, but if you think something needs fixing lmk?

@Loirooriol
Copy link
Contributor Author

Yes, I would like https://drafts.csswg.org/css-grid/#valdef-grid-template-columns-fit-content to explain what to do with indefinite percentages, just like https://drafts.csswg.org/css-grid/#valdef-grid-template-columns-length-percentage does.

If it's supposed to behave like minmax(auto, max-content), explicitly say so. Seems the most reasonable, but e.g. auto could also make sense. I believe there is no difference in practice, since when the align-content and justify-content properties are used, the percentages should be definite. But it should be properly defined anyways.

@fantasai
Copy link
Collaborator

fantasai commented Feb 7, 2019

If the two possible interpretations you can come up with both yield the same behavior, then does it really require clarification?

(This section of the spec is referenced by authors. If it's not necessary for correctness to add a note about obscure details, it's probably better to leave them out.)

If it's not clear clear that the argument to fit-content() is to be interpreted as a track size like any other track size, though, I can clear that up... d110d63

@Loirooriol
Copy link
Contributor Author

If the two possible interpretations you can come up with both yield the same behavior

Well I'm not completely sure if they always yield the same behavior. Can you confirm if it's the case? I still haven't pored over the part about track expansion by align-content and justify-content.

If it's not clear clear that the argument to fit-content() is to be interpreted as a track size like any other track size

But the problem is that this is not really the case, because indefinite percentages are treated as auto, but fit-content(auto) is not allowed. I guess if it existed it would behave according to

This is essentially calculated as the smaller of minmax(auto, max-content) and minmax(auto, limit).

and AFAIK minmax(auto, max-content) <= minmax(auto, auto), so the fit-content would be treated as minmax(auto, max-content)

So if you want to leave the spec as-is it's not that bad but I don't think it's completely clear.

@fantasai
Copy link
Collaborator

fantasai commented Feb 7, 2019

Well I'm not completely sure if they always yield the same behavior. Can you confirm if it's the case?

Well, yeah. auto track size >= max-content, and fit-content() intrinsically imposes a max-content maximum.

@fantasai fantasai added the Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. label May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed Accepted as Editorial Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-grid-1 Tracked in DoC
Projects
None yet
Development

No branches or pull requests

2 participants