Comparing itext:develop...bechte:develop · itext/itext-java
Commits on Dec 12, 2024
-
add support for nth-last pseudo class selectors
With this commit the following CSS3 pseudo classes will be supported: - :nth-last-child(an+b) and - :nth-last-of-type(2a+b) This is especially helpful to format tables with a fixed number of columns, by using a combination of :nth-child and :nth-last-child. Example, given the following markup: ``` <html> <body> <table> <tr> <th>First Column</th> <th>Second Column</th> <th>Third Column</th> <th>Fourth Column</th> <th>Fifth Column</th> </tr> <tr> <td>Line 1a</td> <td>Line 1b</td> <td>Line 1c</td> <td>Line 1d</td> <td>Line 1e</td> </tr> </table> <table> <tr> <th>First Column</th> <th>Second Column</th> <th>Third Column</th> <th>Fourth Column</th> </tr> <tr> <td>Line 1a</td> <td>Line 1b</td> <td>Line 1c</td> <td>Line 1d</td> </tr> </table> </body> </html> ``` The following styles can be used to format the tables, such that the four-column table's last three columns will align with the last three columns of the five-column table: ``` table tr th:nth-child(1):nth-last-child(5) { width: 30%; } table tr th:nth-child(2):nth-last-child(4) { width: 10%; } table tr th:nth-child(3):nth-last-child(3) { width: 20%; } table tr th:nth-child(4):nth-last-child(2) { width: 20%; } table tr th:nth-child(5):nth-last-child(1) { width: 20%; } table tr th:nth-child(1):nth-last-child(4) { width: 40%; } table tr th:nth-child(2):nth-last-child(3) { width: 20%; } table tr th:nth-child(3):nth-last-child(2) { width: 20%; } table tr th:nth-child(4):nth-last-child(1) { width: 20%; } ```