Skip to content

Instantly share code, notes, and snippets.

@Zodiase
Last active December 5, 2016 16:21
Show Gist options
  • Save Zodiase/b7f4a8591eea965816becc76338f652c to your computer and use it in GitHub Desktop.
Save Zodiase/b7f4a8591eea965816becc76338f652c to your computer and use it in GitHub Desktop.
Github code printing CSS
@media print {
/* Hide everything other than code. */
body.page-blob .header[role=banner],
body.page-blob [role=main] .pagehead.repohead,
body.page-blob [role=main] .repository-content > :not(.file),
body.page-blob [role=main] .repository-content > .file > .file-header > .file-actions,
body.page-blob .site-footer-container {
display: none;
}
/* Maximize code area. */
body.page-blob [role=main] .repository-content > .file {
display: block;
position: absolute;
top: 0;
right: 0;
bottom: auto;
left: 0;
margin: 0;
background: white;
}
}
@Zodiase
Copy link
Author

Zodiase commented Dec 5, 2016

Existing issue:

  • body.page-blob is used to determine if the current page is a code page. Without body.page-blob, the styling blanks all pages other than code since there's no code on those pages. However .page-blob is added unreliably by Github; seems like it is only checked and added on page load and won't be updated for route changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment