Preventing Additional Blank Pages When Printing with CSS
When printing HTML documents using a CSS property, users may encounter an issue where an extra blank page is printed before or after the intended content. To resolve this issue, consider the following solutions:
One approach is to use the page-break-after property with a value of always. However, this can introduce an extra blank page before the content. To avoid this, try setting page-break-before to always.
Alternatively, a more effective method is to utilize media queries specifically for printing purposes, such as:
@media print { html, body { height: 99%; } }
By setting the height of the HTML and body elements to 99% within the print media query, you can eliminate any additional blank space that may be causing the extra page to be printed.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3