-
-
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
Support CSS Grid layout #2121
Support CSS Grid layout #2121
Conversation
I tried to test it and installed the grid branch, but I'm unable to get grid to work. What am I doing wrong? See attached an example HTML and resulting PDF. |
Thanks for testing the branch! It looks like you’ve tested the The result I get with the branch is better than what you get, but there’s a problem in the height of rows because the page is too narrow. We’ll fix that! (We’ve also added the support of legacy |
@LukasKlement We fixed the problem (there even already was a TODO in the code for this!), here’s what we get: |
Works great on my (very simple) layout. Very appreciative that grid support is finally getting added! |
This is great! I tried to align the terms of a description list with their first description element:
Using the following css:
This leads to the situation where
Any idea how to avoid this workaround? Apart from this, I encountered no other issues while using the grid system, thanks a lot. |
Hi @schneebuzz, Thanks a lot for testing, and thanks for your failing example. Good news: it’s now fixed! 😄 |
We’ll merge this branch in a couple of days, last chance to test! |
…low validation and tests
Fix #543.
This pull request adds initial support of CSS Grid layout.
🙏🏽 Please test this branch. 🙏🏽
You can install it with
pip install git+https://github.com/Kozea/WeasyPrint@grid
. Please report your feedback in a comment on this pull request, even to say that everything works for you! Don’t open other issues.This work is the "first step" of a full CSS Grid layout. Many features are already supported, but some are not supported yet. A "second step" will be necessary to get a more complete support.
The code added for Grid is pretty clean, it follows the algorithm provided by the specification. The situation is much better than for Flex, and we can expect to keep most of this code unmodified in the future. Missing and buggy features are mainly caused by missing code, not by a broken code structure.
The current version is regularly tested using the W3C testing suite for Grid, there’s no crash for the 1500+ tests and references (even if some tests fail, of course).
The current algorithm is, as usually in WeasyPrint, a bit naive. We’ve put the accent on code clarity to improve readability and maintainability. We duplicated some lines on purpose, mainly to improve debugging sessions. We’ll probably keep this "simple" code for the next version and improve it (for performance and concision) in the future, when we have more experience and more tests.
Here are non-exhaustive lists of supported/unsupported features.
Supported:
display: grid
,grid-auto-*
,grid-template-*
and othergrid-*
properties,grid
and othergrid-*
shorthands,fr
unit),repeat(X, *)
,minmax()
,align-*
andjustify-*
alignment properties,gap
and*-gap
properties for gutters,dense
auto flow,z-index
,order
,Unsupported or buggy:
display: inline-grid
,grid-auto-flow: column
,repeat(auto-fill, *)
andrepeat(auto-fit, *)
,auto
margins for grid items,span
with line names,span
for flexible tracks,safe
andunsafe
alignments,min-width
,max-width
,min-height
,max-height
on grid items,min-content
andmax-content
cases,Before merging this pull request, we’ll: