Extra blank page when I print (except in IE) - is it my print css?
Most of the times you’ll specify
html, body { width: 100%; height: 100%; }
The print driver in your browser doesn’t like this. So to fix that just add this to your print.css file
html, body { height: auto; }
No more blank page printing.
the solution is explained at this page hope helps everyone
Related videos on Youtube
tekiegirl
A creative & proactive software architect ENFP-T Campaigner / Inspirer / Champion Some of my interests: #neurodiversity #diversityintech #womenintech
Updated on September 15, 2022Comments
-
tekiegirl over 1 year
I am using print css to hide certain elements and also to stop page breaks when I don't want them. The user can choose to hide sections before they print.
My problem is that when I print-preview there is always an extra blank page (at the end in Chrome and Firefox, and at the beginning in Opera) and I cannot figure out why. IE does not have a problem, no extra pages (which is shocking...)
I would greatly appreciate some input. I have tried making the container div page-break-after: avoid; and page-break-after: auto; but neither worked. Also taking out the table.plain { page-break-inside:avoid; } did not make a difference.
The exclude class is added to a table when the user clicks the hide icon. This works and anything with the exclude class does not show in print. The final page the user wants to print may fit on one page or may not.
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 in advance for your help :)
-
Nix almost 11 years@tekiegirl Maybe you could debug it by loading the print stylesheet in the browser?
-
-
Larry Silverman almost 8 yearsSolved it for me. I implemented it using a media query in SCSS.
-
H.Rabiee almost 6 yearsJust a broken link in there :(.