Re: [csswg-drafts] [css-sizing] Possible to reproduce a `<div>`'s `width: auto` behavior on any element? (#7427)

Thank you so much for the insightful response @Loirooriol.

> Strictly speaking, I think what you want is a way for resolving justify-self: normal as if the element wasn't replaced.

That very well could be! I didn't realize that `justify-self` was supposed to have an effect in block layout. That doesn't seem to be supported by any browser at the moment ([see Codepen](https://codepen.io/benface/pen/RwyQJRW)), but [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self) does say:

> In block-level layouts, it aligns an item inside its containing block on the inline axis.

Strangely, [the "Browser compatibility" table](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self#browser_compatibility) doesn't have a "Supported in Block Layout" row, nor did I find the feature listed on [caniuse.com](https://caniuse.com/?search=justify-self).

I would add that the problem isn't necessarily about "replaced" elements. As I mentioned in my (way too long) initial post, it affects `<table>` as well.

> But I'm not convinced that this is worth doing. It seems to me that e.g. if you turn the container into a flex container, then you can also make the button adapt to being a flex item.

Definitely, there are multiple ways to achieve the desired flexibility by allowing some kind of communication between the component and its consumer (e.g. in terms of React: props or context; or in terms of pure CSS: parent class + direct child selector, custom property, etc.). But the point is that the consumer should not _have_ to do anything IMO. There should be a way to make it "just work", like it does with other element types.

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


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

Received on Wednesday, 28 September 2022 21:18:41 UTC