Images are getting resized in Print Preview

Kalish picture Kalish · Oct 4, 2012 · Viewed 11.4k times · Source

I have several images(not background images) on my webpage, When I see the Print Preview at 100% scale, images looks fine, but My problem is that when I do a print prview with Shrink to fit scale, all the images are coming smaller than the actual size. I have not supplied any width or height attribute on IMG tag so I assume that in print preview it will load as they appear on screen. I have used below css for print media for IMG but it did not work

img {max-width:100%; }

I am expecting the same image dimension in Shrink to fit and 100% scale.

Is this possible? am I missing something in print css? Please advice.

Answer

bakrall picture bakrall · May 16, 2019

While working on my project, when I needed to get the original size of image in print preview, I had to use !important. Otherwise, it wouldn't overwrite the style defined initially for the image on the page.

I also had to modify the height of image containers:

@media print {
      .logo-container,
      .img-wrapper,
      img {
        max-height: none !important;
        height: 100% !important;
}