Re: [csswg-drafts] [css-values-4] inherit() function: like var() for parent value, for any property (#2864)

@tolmasky 
> > For width and height, I think container query units will probably work much better for most use cases, and they're already supported eveyrwhere!
> 
> Unless I'm misunderstanding, that first requires me to make a container query though, right? I can't just say `padding: calc(10 * cqh) calc(10 * cqw)`, right? I have to first create an arbitrary container query so that `cqw` and `cqh` actually refer to the right thing? This seems way more cumbersome than being able to just refer to your parent's width and height, the way percentages implicitly (but confusingly do), and the way `inherits` does. I initially came to this bug trying to find if there was anything like `pw` and `ph` (to match `vw` and `vh` and `cqw` and `cqh`), and eventually was led to this bug saying "We don't need that since you can just do `inherit(width)`, only to then scroll to the end and discover those were dropped. So back to square one.

You just need to set appropriate `container-*` properties, not a container query. And soon (much sooner than `inherit()` may ship) you'll be able to refer to containers higher than the closest one.
`inherit()` will not do what you want most of the time, because it would only give you a parent width/height, and only if it's explicitly set, which it usually is not. Whereas cq units will actually be computed based on the used dimensions.

@brandonmcconnell 


> That's my understanding as well. Moreover, in some of my container query testing, I've noticed that setting up a container produces some wonky and unexpected results to the element that is declared as a container, causing its height to essentially zero out, if not explicitly set.

This sounds like a potential browser bug?

> Being able to inherit those computed values would be a huge win in this case. Most of the times I've set up a container, I've done so specifically to use its width and height, so this seems like it would be easier to reach for in simpler circumstances like this.

See above, you wouldn't be inheriting computed values with `inherit()`. 

> Also, I understand it would be easier on the first pass of this feature to only support CSS custom properties with the `inherit()` function, but in 99% of cases, can't CSS custom properties be naturally inherited without using `inherit()`, except when a CSS custom property is set to `inherits: false` using `@property`?

a) Most use cases for `inherit()` are around using the inherited value of property A in property B, which is *not* something you get with regular inheritance.
b) Regular inheritance doesn't allow you to do math. `--foo: calc(var(--foo) + 1)` is IACVT, whether `--foo` inherits or not. `--foo: inherit` is valid, but you can’t do anything with it (though we should probably enable that).

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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 29 December 2023 17:55:34 UTC