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

Unable to set table column width on tables td's if a th exists #172

Closed
stevenlaidlaw opened this issue Mar 6, 2014 · 11 comments
Closed

Comments

@stevenlaidlaw
Copy link

If a 'table > thead > tr > th' is set, weasy is not able to set the column widths on td's below it. This is a problem when trying to set widths on table columns where the table header has a colspan greater than 1.

Example:

<table>
    <thead> 
        <tr>
            <th colspan="2">The column width will not work in weasy</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Hello</td>
            <td>Clarice</td>
        </tr>
    </tbody>
</table>
table > tbody > tr > td:first-child {
    width: 20%;
    text-align: left;
}
@SimonSapin
Copy link
Member

I wouldn’t be surprised if we do colspan wrong in the automatic column width algorithm. @liZe does that ring a bell?

@liZe
Copy link
Member

liZe commented Mar 7, 2014

I think that percentages are not handled at all when no width is set to the table, even without colspans. I'll check that.

@SimonSapin
Copy link
Member

http://dbaron.org/css/intrinsic/ describes algorithms we could implement to handle this kind of thing. At the moment, it’s the closest thing in existence to a spec of what browsers do.

@liZe
Copy link
Member

liZe commented Mar 7, 2014

Soooooo easyyyyyyyy!

@SimonSapin
Copy link
Member

Of course. It’s just a small matter of programming :)

@stevenlaidlaw
Copy link
Author

Apologies, I should have clarified that even with a table width of 100% and table-layout of fixed this still happens, but from what you've written in response it seems like you're onto it anyway. :)

@eldamir
Copy link

eldamir commented Jan 4, 2016

This is still a real pain. Any fix available?

I have a table with 6 columns, and each column has a width set, which looks great in Chrome, but with weasyprint, these widths are ignored, and all columns seem to be equally distributed 😦

@stevenlaidlaw
Copy link
Author

I don't think anyone is working on Weasy anymore. The hacky workaround I use is just to have an invisible th row above the normal one, and hide all the margins, padding, borders, etc, then just set the widths on that. It's bad code, but it's what you have to do to get it working in Weasy :(

@liZe
Copy link
Member

liZe commented Jan 12, 2016

You can look at #291.

Your specific case is maybe the worst case for this algorithm (the width of the table is a too high, it's the same rendering as Chrome for example), but at least it takes care of the percentages. It's much better for other cases.

Feel free to tests and reports bugs!

@liZe
Copy link
Member

liZe commented Jan 15, 2016

@eldamir @stevenlaidlaw last call for tests! You can try #291 if you want.

@liZe
Copy link
Member

liZe commented Jan 25, 2016

@eldamir @stevenlaidlaw it's merged in master.

@liZe liZe closed this as completed Jan 25, 2016
jsonn referenced this issue in jsonn/pkgsrc Feb 19, 2016
Version 0.26
------------

Released on 2016-01-29.

New features:

* Support the `empty-cells` attribute.
* Respect table, column and cell widths.

Bug fixes:

* `#172: <https://github.com/Kozea/WeasyPrint/issues/172>`_:
  Unable to set table column width on tables td's.
* `#151: <https://github.com/Kozea/WeasyPrint/issues/151>`_:
  Table background colour bleeds beyond table cell boundaries.
* `#260: <https://github.com/Kozea/WeasyPrint/issues/260>`_:
  TypeError: unsupported operand type(s) for +: 'float' and 'str'.
* `#288: <https://github.com/Kozea/WeasyPrint/issues/288>`_:
  Unwanted line-breaks in bold text.
* `#286: <https://github.com/Kozea/WeasyPrint/issues/286>`_:
  AttributeError: 'Namespace' object has no attribute 'attachments'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants