Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing elements that appear when printing, using print.css stylesheet [duplicate]

Problem

I'm currently using a stylesheet print.css to remove elements and some styling to create a printer-friendly page, but I can't seem to remove four things that appear in the corners of the page, but are not in the HTML: pagination, date printed, title of page, URL of page

Possible solution?

I've seen this example from the LA Times that shows elements that are not in the HTML, but typically appear when printed being removed: http://graphics.latimes.com/oscar-bingo-2015/

like image 468
Andrew Nguyen Avatar asked Jun 18 '26 18:06

Andrew Nguyen


1 Answers

There are quite a few posts on the subject here on StackOverflow:

Looks like it works by using the @page media property in combination with the print media property:

@media print {
    @page { margin: 0; }
  }

However, it only seems to work in Chrome (for the moment). Firefox can be made to oblige, though. Elsewhere, it was suggested to create PDF on the fly - or to use JavaScript to set at least the page title to an empty string.

Also, I'd question why you'd want to hide something your users are usually used to have control over.

To answer your question, though: The LA Times use bootstrap, which sets the page margin as follows:

...@page{margin:.5cm}...
like image 99
Christian Avatar answered Jun 21 '26 10:06

Christian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!