Skip to content
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

tr with fixed height shrinking below height of content #1968

Closed
ericbf opened this issue Sep 19, 2023 · 2 comments
Closed

tr with fixed height shrinking below height of content #1968

ericbf opened this issue Sep 19, 2023 · 2 comments
Labels
bug Existing features not working as expected
Milestone

Comments

@ericbf
Copy link

ericbf commented Sep 19, 2023

It seems that WeasyPrint treats the height of tr elements different than the browser, causing inconsistent table row heights for table rows with a fixed height less than the size of the content therein.

In the browser, if the height of a tr is less than the height of the content, the tr will take the height of the content instead:

Screenshot 2023-09-19 at 2 21 29 PM

However, when that same markup is rendered into a PDF with WeasyPrint, the tr will actually use the lesser height, not expanding to the height of the content as expected:

Screenshot 2023-09-19 at 2 21 49 PM

This is not the case for the td elements, where setting a height smaller than the content does not cause the td to shrink below the size of the content (see the same example above).

Maybe it has to do with the padding on the tds? It seems to be squashing the vertical cell padding. Not sure exactly what behavior is taking place, technically.

Here’s the markup for the example:

<table style="border-collapse: collapse; width: 100%; border: 1px solid rgb(126, 140, 141);" border="1">
	<tbody>
		<tr style="height: 100px;">
			<td style="padding: 5px; vertical-align: middle; border: 1px solid rgb(126, 140, 141); width: 100%;">Tall Row</td>
		</tr>
		<tr>
			<td style="padding: 5px; height: 100px; vertical-align: middle; border: 1px solid rgb(126, 140, 141); width: 100%;">Tall Cell</td>
		</tr>
		<tr style="height: 5px;">
			<td style="padding: 5px; vertical-align: middle; border: 1px solid rgb(126, 140, 141); width: 100%;">Short Row</td>
		</tr>
		<tr>
			<td style="padding: 5px; height: 5px; vertical-align: middle; border: 1px solid rgb(126, 140, 141); width: 100%;">Short Cell</td>
		</tr>
	</tbody>
</table>
@ericbf
Copy link
Author

ericbf commented Oct 2, 2023

Hello is anyone going to triage this one?

@grewn0uille
Copy link
Member

Hi,

According to the specification :

The minimum height of a row is the maximum of:

  • the computed height (if definite, percentages being considered 0px) of its corresponding table-row (if nay)
  • the computed height of each cell spanning the current row exclu
  • the minimum height (ROWMIN) required by the cells spanning the row.

So the height of the third tr should be at least 10px (sum of paddings) + line height.
It’s indeed a bug 🐛

@grewn0uille grewn0uille added the bug Existing features not working as expected label Oct 2, 2023
alexandergitter added a commit to alexandergitter/WeasyPrint that referenced this issue Jan 14, 2024
@grewn0uille grewn0uille added this to the 61.0 milestone Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing features not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants