scale html table before printing using css

后端 未结 3 1537
死守一世寂寞
死守一世寂寞 2020-12-25 12:55

I have a table as the entire content of an HTML document (for legitimate table purposes...it is table data, not for layout). Some cells have widths and heights specified (n

相关标签:
3条回答
  • 2020-12-25 13:35

    I know I'm raising the dead, but for future search results reference:

    I ran into a problem with super wide tables causing all the browsers to calculate the height incorrectly and repeat the thead multiple times on single pages - my solution was to apply zoom: 80% to the body (% varies based on your needs) which forced our page to effectively fit for print and the thead then was repeated properly at the top of every page. Perhaps trying zoom will work where transform did not.

    0 讨论(0)
  • 2020-12-25 13:56

    I ended up rewriting the whole table with percentage sizes applied as classes and then was able to scale the page for printing. Not sure why the browser was ignoring my print styles regarding the transform but converting the table from fixed sizes to proportional sizes has enabled me to scale it with CSS and the issue is gone.

    0 讨论(0)
  • 2020-12-25 14:01

    You should use the media types

    @media print {
        body {transform: scale(.7);}
        table {page-break-inside: avoid;}
    }
    

    So, this styles will by applying only in print preview mode. http://www.w3.org/TR/CSS21/media.html

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