Skip to content

Instantly share code, notes, and snippets.

@ps2goat
Created December 5, 2020 20:55
Show Gist options
  • Save ps2goat/de7db5295fc70c2fd642e96509c3a593 to your computer and use it in GitHub Desktop.
Save ps2goat/de7db5295fc70c2fd642e96509c3a593 to your computer and use it in GitHub Desktop.
Shrink whitespace for printouts
/* place in a the head tag of html
It will remove all ridiculous page break directions, overflows, and inline-block display types, which cause issues.
Then re-applies hiding to elements that need it. could be better but works /shrug
Originally used on a health site's receipt page that was 3 pages long but should have fit on 1 page at 100% scale.
*/
<style type="text/css">
@media print {
* {
page-break-before: avoid!important;
page-break-after: avoid!important;
overflow: auto!important;
display:inline!important;
}
head, link, style, script {
visibility:hidden!important;
display: none!important;
}
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment