Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: Disable Header & Footer From Print Preview Chrome

one of my application is web based POS(Point Of Sale). so while printing invoices in chrome. the page header and the page footer automatically inserted by the browser that I want to supress via the page and without user intervention..

I applied some CSS over-here in print-media,

@media print {
 #header, #footer { 
    visibility: hidden !important;
    display: none !important;
 }
}

But it's not applying, maybe the selector isn't correct?

And I also tried by reducing the margin as well, but its cutting/ overriding the page-content, if print has multiple pages.. And one more thing, i don't want to disable the print preview option for chrome..

Any one has good solution for this?

Best Regards..

like image 485
Niks Jain Avatar asked Jul 16 '12 11:07

Niks Jain


People also ask

How do I hide the header in HTML?

Approach 1: Select the header using a CSS selector and modify the style property such that the value of the display property is set to none. This will hide the selected table header element from the page. Example: html.

How do I remove a header from a website?

Go to Insert > Header or Footer, and then select Remove Header or Remove Footer.

How do I hide the header in WordPress CSS?

In the WordPress admin panel, click Appearance > Customize. To remove the header, click Header > Header layout and for the Layout setting select None.


1 Answers

use

@page{margin:0px auto;}

in your css script. This will most likely throw off your page layout when printing, so you'll probably want to add a #container div with the correct padding to make your page look good again. Only tested on Google Chrome.

like image 51
Michael Avatar answered Oct 17 '22 03:10

Michael