I use print css to hide certain elements, and also to stop page breaks when I don't want them. User can hide sections before printing.
My problem is that when I print previews, there is always an extra blank page (at the end in Chrome and Firefox, and at the beginning in Opera), and I canโt understand why. IE has no problems, no extra pages (which is shocking ...)
I would really appreciate some material. I tried to make the container div div-break-after: avoid; and page-break-after: auto; but no one worked. Also take out table.plain {page-break-inside: avoid; } irrelevant.
The exclude class is added to the table when the user clicks the hide icon. This works, and anything with the exclude class does not appear in print. The final page that the user wants to print can fit on one page or cannot.
Here is my html:
<body> <div id="main"> <div id="content"> <div id="side" class="exclude"> ...logo, etc, shown at side on screen... </div> <div id="data"> <table class="printOnly plain printHeader"> ...logo, etc, to print at top... </table> <div> <table class="detail plain"> <tbody> <tr> <td class="rel"> <div class="abs exclude visibility"> <a href="#" class="show ico-show ico hid">Show</a> <a href="#" class="hide ico-hide ico">Hide</a> </div> <h3>Contact</h3> </td> </tr> ...more tr with contact details... </tbody> </table> ...more tables with other details... </div> </div> //data </div> //content </div> //main </body>
Here is my print css:
@media print { .exclude { display: none !important; } .printOnly { display:block !important; } div#data, div#data div { width: 98% !important; border: none !important; } table.plain { page-break-inside:avoid; } }
Many thanks for your help:)
tekiegirl
source share