Weasyprint: How to override CSS table style of weasyprint

Created on 6 Feb 2017  路  4Comments  路  Source: Kozea/WeasyPrint

My os is: Debian Jessie in Docker
weasyprint==0.34
python==3.6.0

I can override background color, width, heigh, but I can not override the table style
How can I do it?

CSS question

Most helpful comment

<style>
  table {
    border-collapse: collapse;
    color: #333;
    margin: auto;
  }

  tr:nth-child(odd) {
    background: #eee;
  }

  tr:first-child {
    background: white;
  }

  td, th {
    border: 1px solid #ccc;
    padding: 0.5em;
  }

  th {
    border: none;
    text-align: center;
  }
</style>

<table>
  <tr>
    <th>dog</th>
    <th>cat</th>
    <th>horse</th>
    <th>iguana</th>
  </tr>
  <tr>
    <td>dog</td>
    <td>cat</td>
    <td>horse</td>
    <td>iguana</td>
  </tr>
  <tr>
    <td>dog 2</td>
    <td>cat 2</td>
    <td>horse 2</td>
    <td>iguana 2</td>
  </tr>
  <tr>
    <td>dog 3</td>
    <td>cat 3</td>
    <td>horse 3</td>
    <td>iguana 3</td>
  </tr>
  <tr>
    <td>dog 4</td>
    <td>cat 4</td>
    <td>horse 4</td>
    <td>iguana 4</td>
  </tr>
</table>

test

All 4 comments

<style>
  table {
    border-collapse: collapse;
    color: #333;
    margin: auto;
  }

  tr:nth-child(odd) {
    background: #eee;
  }

  tr:first-child {
    background: white;
  }

  td, th {
    border: 1px solid #ccc;
    padding: 0.5em;
  }

  th {
    border: none;
    text-align: center;
  }
</style>

<table>
  <tr>
    <th>dog</th>
    <th>cat</th>
    <th>horse</th>
    <th>iguana</th>
  </tr>
  <tr>
    <td>dog</td>
    <td>cat</td>
    <td>horse</td>
    <td>iguana</td>
  </tr>
  <tr>
    <td>dog 2</td>
    <td>cat 2</td>
    <td>horse 2</td>
    <td>iguana 2</td>
  </tr>
  <tr>
    <td>dog 3</td>
    <td>cat 3</td>
    <td>horse 3</td>
    <td>iguana 3</td>
  </tr>
  <tr>
    <td>dog 4</td>
    <td>cat 4</td>
    <td>horse 4</td>
    <td>iguana 4</td>
  </tr>
</table>

test

Let me confirm your answer tomorrow. Thailand time is neary finish now

Thank you very much. It done

Was there a change? Because with WeasyPrint version 0.40 it seems not to work. See https://stackoverflow.com/q/46346852/562769

Was this page helpful?
0 / 5 - 0 ratings

Related issues

knyttl picture knyttl  路  4Comments

bjornasm picture bjornasm  路  3Comments

zopyx picture zopyx  路  5Comments

thejasechen picture thejasechen  路  3Comments

mjbeyeler picture mjbeyeler  路  4Comments