W3C home > Mailing lists > Public > public-css-archive@w3.org > August 2019

Re: [csswg-drafts] [media-queries][css-sizing] Support <number> (and therefore calc) as a <ratio> (#3757)

From: Amelia Bellamy-Royds via GitHub <sysbot+gh@w3.org>
Date: Wed, 28 Aug 2019 17:34:57 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-525845920-1567013696-sysbot+gh@w3.org>
My current proposal, after the discussion on the call:

For simplification (e.g., reducing calc to a single value), treat each `<number>` as independent.
If only one number was specified, treat the second number as 1.
Then serialize as `<number1>/<number2>`.

This is all consistent with how the aspect-ratio is currently serialized ([demo](https://codepen.io/AmeliaBR/pen/8458d7a2c47d923f12165a9c7c01f252?editors=0111), Chrome and Firefox tested).

For dealing with zeros, I think we just accept them & use them in a way consistent with other standard computer math rules, as we've defined [elsewhere for calc and comparator functions](https://drafts.csswg.org/css-values/#calc-type-checking):

- An aspect ratio of 0/n in a media query will be less than any possible aspect-ratio of the display. 
- An aspect ratio of n/0 (for positive n) will be greater than any display.
- 0/0 will always be invalid and never match anything.
- For use in the `aspect-ratio` property, these will either result in values of zero being calculated (e.g., when calculating height from a defined width using an aspect ratio of 0/n, you get a height of 0) or with invalid results (e.g., infinite height) that cause the width/height calculations to fallback to whatever is the next step in the layout algorithm.

For negative numbers, I'm OK with either option:

- Force both numbers in the faction to be non-negative,so the syntax for `<ratio>` becomes `<number [0,∞]> [ / <number [0,∞]> ]?`; ***or***
- Allow negative numbers, and if the final aspect ratio is negative (i.e., if one or the other number is negative, but not both), that is clamped to zero in practice because width, height, and the display aspect ratio can never have negative values.

GitHub Notification of comment by AmeliaBR
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3757#issuecomment-525845920 using your GitHub account
Received on Wednesday, 28 August 2019 17:34:59 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:52 UTC