WeasyPrint: Table style "width" property ignored in latest version
I use for “table” tag this CSS properties:
width:-moz-fit-content;
width:-webkit-fit-content;
width:-ms-fit-content;
width:fit-content;
All was working fine till I changed to Debian Stretch and upgraded to latest WeasyPrint. Now, tables doesn’t adapt its width to the page+margin width, overflowing and being cropped at right margin.
Edit: In the terminal, weasyprint shows:
WARNING: Ignored `width:unset` at 268:3, invalid value.
WARNING: Ignored `width:-moz-fit-content` at 273:3, invalid value.
WARNING: Ignored `width:-webkit-fit-content` at 274:3, invalid value.
WARNING: Ignored `width:-ms-fit-content` at 275:3, invalid value.
Please, could you fix it??

In the image you can see in the left how it should be displayed / printed (in fact, is printed right directly from the browser) and in the right, the output from WeasyPrint nowadays.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 28 (14 by maintainers)
Commits related to this issue
- Fix a contribution according to the table layout unofficial spec Related to #666. — committed to Kozea/WeasyPrint by liZe 6 years ago
- py-weasyprint: Update to 43. Version 43 ---------- Released on 2018-11-09. Bug fixes: * `#726 <https://github.com/Kozea/WeasyPrint/issues/726>`_: Make empty strings clear previous values of nam... — committed to NetBSD/pkgsrc by kleink 6 years ago
This Issue appears as one of the first results when searching “weasyprint fit-content”, so I’m writing this post in case anyone needs an alternative to
fit-content. First of all, Weasyprint does NOT supportfit-content, a way to replace it is withdisplay: table, because this uses tables, which were (or are) a way to organize HTML content in the old days.Say for example that you want to center and fit to content your paragraphs, the <p> elements. This will do
If you just want to fit to content the same as
fit-contentdoes, then delete the line that saysmargin: 0 auto;.YOU DID IT!!! I didn’t believe it (cause I’m sure it was not easy for you as you told me), so I created the PDF file at least three times, and it works perfectly!!!
Now I need to find out what where is my mistake in CSS fonts code, cause curiously now I have not condensed font in the browser!!! But for sure is something I’m doing wrong, so I’m going to find what is just now.
Then I’ll test with similar (even larger) and a little more complex tables, but I’m sure all will work like a charm with weasyprint!! I’ll report you next news!
I finally know why: WeasyPrint doesn’t support woff2 fonts, because it relies on fontconfig that doesn’t support woff2. Using another format will work.