-
Notifications
You must be signed in to change notification settings - Fork 719
[css-flexbox] Flex basis and box-sizing #316
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
Comments
Yeah, it would be nice if flex would work with the box-sizing property, but it does complicate things; the border+padding would have to act as an additional min-size constraint, effectively. I'm also very unsure whether it's compatible to make such a change now. Perhaps we could add a property switch that makes it pay attention? |
The original intent of |
@dholbert @cbiesinger @atanassov Comments here? Is this something we can fix? |
In particular, would it be okay to make the necessary edits so that the following: .flexbox {
display: flex;
width: 300px;
}
.flex-item {
box-sizing: border-box;
border: 20px;
}
.flex-item:nth-child(1) {
flex: 1;
}
.flex-item:nth-child(2) {
flex: 2;
} results in the first item being 100px wide (20px border, 60px content, 20px border) and the second item being 200px wide (20px border, 160px content, 20px border)? Today you instead, unfortunately, get the first item being 113px wide (20px border, 73px content, 20px border) and the second being 186px wide (20px border, 146px wide, 20px border), because they're distributing the 220px of free space in a 1:2 ratio. |
Adding myself to the thread, but given how many websites are using flexbox today combined with a framework that sets border-box on all elements by default, this breaking-change seems unlikely to be webcompatible to me. Maybe adding |
True, but I think in most cases the current behavior is either unintended or unnoticed. I think it's worth fixing if we can. This is the one place we screw up and effectively don't use border-box sizing even when you've specified it. |
The CSS Working Group just discussed
The full IRC log of that discussion |
CSSWG resolved to try to fix this! Blink team has volunteered to try implementing; if they can pull it off without breaking anything, other vendors will follow. |
Reopening for testcase need. |
Just to be clear. The behavior has not change since this issue report right? The example given by @tabatkins still leads to a distribution of 113px and 187px with a 300px-wide flexbox with two border-box-enabled items that have a border of 20px in a flex ratio of 1:2. I made a quick pen to demonstrate the issue again: The spec reads
So can we agree that |
@cbiesinger I can't find any ticket in Blinks tracker that relates to the resolution/commit discussed here. Since @tabatkins mentioned volunteering your efforts for the change in Blink and you've recently worked on flex/box-sizing interactions with aspect-ratio (https://bugs.chromium.org/p/chromium/issues/detail?id=1166834 / ede56bd#r40863567), I'm wondering if you have any ideas on the state of this issue? cc @fantasai |
Any update? |
cc @davidsgrogan , I haven't worked on flex in several years now |
Uh oh!
There was an error while loading. Please reload this page.
I noticed a problem while working with flexbox last week:
If we add padding or borders, the flex items are not actually distributed at thirds according to the algorithm, even if box-sizing is set to border-box. This is in direct contradiction to our examples/descriptions in https://www.w3.org/TR/css-flexbox-1/#flex-common
The way things are, it's not possible to get things to align unless you do some fancy math with the padding and borders... the avoidance of which is exactly the point of having the box-sizing property. I'm somewhat afraid it's not possible to fix this anymore. :( But for sure it's got to be annoying for authors...
The text was updated successfully, but these errors were encountered: