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

Re: [csswg-drafts] [css-values-4] Way to set height, max-height, min-height relative to width (#5461)

From: ferenci84 via GitHub <sysbot+gh@w3.org>
Date: Fri, 21 Aug 2020 18:50:26 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-678438257-1598035825-sysbot+gh@w3.org>
Can we go a little more deeply with this discussion? I think this is an important gap in the spec.

As I get it right, you must be able to use the length units in every context, while some specific property value may be invalid in some context. Am I right?

Is it possible for such a sizing to exist in other spec part? For example the percentage sizing section has specific rules about how to resolve cyclic dependencies:

Also it specifically says: 
> Otherwise, the percentage is resolved against the containing block’s size. (The containing block’s size is not re-resolved based on the resulting size of the box; the contents might thus overflow or underflow the containing block).

I believe there *is* a solution to connecting width and height in design in *any* way. Some ideas:
1. A sizing similar to the existing percent sizing with the same fallback mechanism already worked out
2. Having variables that can be referred to: for example the 4 auto-determined sizes: https://www.w3.org/TR/css-sizing-3/#auto-box-sizes and in any context in which the requested value is not available, it would resolve to some fallback value.
3. Additional keywords added to specific properties, just like fit-content(<length percentage>)

Also there are existing cases where either the width depends on height or vice versa:
1. boxes with an intrinsic aspect ratio: https://www.w3.org/TR/css-sizing-3/#intrinsic-sizes
2. All vertical box properties except height, and especially the padding affects the height of the box if the `box-sizing` is set to `border-box`

My motivation is not to resolve that specific example. The problem I spotted that when I needed a solution to set height/min-height/max-height using *any* value that depends on width (it doesn't really matters if it's the box itself or the containing box, or the preferred width or the real width), I found nothing, but hacks (and vw of course). The `aspect-ratio` is a great property for that specific things, however it doesn't work (or very tricky) if a developer want to set min-size or max-size. I think in the CSS of the future there should be less hacks and more convenient solutions.

GitHub Notification of comment by ferenci84
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5461#issuecomment-678438257 using your GitHub account

Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 21 August 2020 18:50:29 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:13 UTC