1

I have a Bootstrap page and I want to print it in A4 size. I have few elements which I don't want to print from this page, I am using this solution to achieve this:

@media print
{    
    .no-print, .no-print *
    {
        display: none !important;
    }
} 

How do I hide an element when printing a web page?

However when I use this, my structure of the page changes. That means if I skip say a text element, then at printing, that space is taken by another element. It should not happen.

I want to print this web page on a certificate template of A4 size.

Community
  • 1
  • 1

2 Answers2

0

Use visibility:hidden instead of display:none. This will preserve the space occupied by the elements while still hiding them. display:none essentially renders the page as if these elements did not exist at all.

@media print {
  .hideprint {visibility: hidden;}
}
Aziz
  • 7,685
  • 3
  • 31
  • 54
0

Using @media print you can set the display, I guess you are using display "none" so the layout changes.

You could use opacity or visibility spite of display. opacity:0 or visibility:hidden will keep the layout untouched, while making the elements dissapear (visually).

miguel-svq
  • 2,136
  • 9
  • 11