Workaround for Chrome 53 printing table header twice on 2nd and later pages?

后端 未结 4 1592
别那么骄傲
别那么骄傲 2021-02-07 08:26

Users of my website need to be able to print web pages consisting of content on the first printed page followed by a table on the second page. A stripped down version is (jsFid

相关标签:
4条回答
  • 2021-02-07 08:48

    My temporary solution:

    thead {
        display: table-row-group;
    }
    
    0 讨论(0)
  • 2021-02-07 08:55

    I posted the same issue to the Chrome feedback channels. My workaround for now was to simply remove my thead elements for a standard table row within the tbody. It's certainly not as semantically pure, but you can pretty simply restyle them with a touch of css.

    Table:

    <table>
    <tbody>
      <tr class="thead">
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
      </tr>
    </tbody>
    <tfoot>
       <tr>
         <td></td>
         <td></td>
       </tr>
    </tfoot>
    </table>
    

    Scss:

    tr.thead {
      td {
        font-weight:bold;
        border-bottom: solid 1px #333;
      }    
    }
    
    0 讨论(0)
  • 2021-02-07 08:59

    I was getting the double header on the second page in chrome when printing

    Adding the following CSS made it appear properly (once)

    thead {
        display:table-header-group;
        break-inside: auto;
    }
    

    Source: https://stackoverflow.com/a/50987624/175071

    0 讨论(0)
  • 2021-02-07 09:04

    This fix worked for me

    thead {
      display: table-row-group;    
    }

    0 讨论(0)
提交回复
热议问题