-
-
Notifications
You must be signed in to change notification settings - Fork 704
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
Incorrect height for flex-direction: column
inside flex-direction: row
#2222
Comments
Thanks for the report. It’s maybe related to #1171. |
Yes it seems like it might be similar (the common denominator is |
Definitely related to this comment: https://github.com/Kozea/WeasyPrint/blob/main/weasyprint/layout/flex.py#L255
body {
max-width: 30em;
margin: auto;
}
section {
border: 1px solid blue;
display: flex;
flex-direction: column;
}
article {
flex: 1;
border: 1px solid green;
margin-top: 1ex;
margin-bottom: 1ex;
} |
Hmm, the last two comments are a different (though vaguely related) issue, it seems. On the browser the available main space is clearly infinite when the main axis is 'height' (i.e. flex-direction is column), but on print media this isn't so clear - is it the remaining space on the page? (Weasyprint thinks so) or is it also infinite (since a flex container could get split across pages)? If it's the remaining space on the page, then the sizing of If it's infinite, then both are wrong, and the reason is that section 9.3.2.D of https://www.w3.org/TR/css-flexbox-1/#algo-main-item is not implemented, as noted here: https://github.com/Kozea/WeasyPrint/blob/main/weasyprint/layout/flex.py#L207 - this is what causes
Do you know what the CSS print media spec says about this? |
So, back to my original problem, the issue here is simply not expanding the flex container in the cross-axis to fit its content. This is likely due to the fact that the code is explicitly setting the |
I may be able to make a draft PR this week. I have heavily annotated the flex code already :) |
Note that #2231 fixes all the issues above as it turns out that yes, they were all related ;-) The flexbox layout code is still broken in many ways though! |
Yes, another flexbox bug! I think I have this narrowed down to the specific problem - in the rather common use case of
display: flex; flex-direction: column
nested insidedisplay: flex; flex-direction: row
, the inner elements are not expanded vertically to fit their contents. In other words, this code:should do this (Chrome):
But actually does this (Weasyprint 62.3):
(the reason I'm not using grid layout is that actually my CSS is a bit more complex and relies on
flex-wrap
andflex-basis
to make a layout of maximum two columns from a sequence of elements, but all of that works fine, it's just the box sizing that's wrong)The text was updated successfully, but these errors were encountered: