WeasyPrint: Don't apply max-width to flex items unless their flex container has an absolute width
Did some styling with Bootstrap, everything works fine except the grid system. Did this in my HTML-File:
<div class="container">
<div class="row">
<div class="col">
</div>
<div class="col">
</div>
</div>
</div>
PDF-File ignores complete the grid system (div class=“col”) from bootstrap
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 20 (10 by maintainers)
Problem is that bootstrap css defines both, a
flex-basisand amax-widthfor thecol-*flex items and that confuses WeasyPrint resulting in wrong column sizes. There a two workarounds to prevent the confusion and achieve the desired (proportional) column widths:Apply an absolute width to the flex container, e.g.:
.row {width: 20cm}This isn’t a good one – 20cm, huh?Hide the (superfluent?)
max-widthfrom WeasyPrint by unsetting it for all.col-*definitions.renders as expected:
Hi, issue still persists for me. Weasyprint 45, bootstrap 4.3.1. The columns are way off and the numbers (below in
<p>) are rendered as images? Simple HTML example:Hi @hybridpicker, Bootstrap 4.x uses a CSS flex layout which is currently not supported by WeasyPrint. However, it seems like it was implemented recently in https://github.com/Kozea/WeasyPrint/pull/579, but I didn’t try it yet. I used for my project a modified version of the column CSS from Bootstrap pre 4.x: https://github.com/senaite/senaite.impress/blob/master/src/senaite/impress/static/css/bootstrap-print.css, but there you need to keep in mind that WeasyPrint does not break in between floating blocks, see here: https://github.com/Kozea/WeasyPrint/issues/36