View Single Post
Old 12-06-2015, 10:19 AM   #2
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,558
Karma: 19620479
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
You can specify sizes in absolute units (cm, in, mm... even px are supposed to be absolute units, not physical pixels).

But I think what you are after is simply "div.cimg img {max-width:100%}". That should show the image at its "natural" size, but resize it down to 100% if it's larger.

Quote:
Originally Posted by rubeus View Post
To solve that the max-width style can be apllied to the img element:

Code:
  <div class="cimg">
    <img alt="" src="../Images/img07.png" style="max-width: 520px"/>
  </div>
Now the image will be resized according to the screen size but this will stop at 520px, the width of the image itself.
Wrong. "px" are absolute units 1/96 inches, if I remember correctly, so it won't prevent the image to be magnified if the device resolution is higher than 96ppi.

Last edited by Jellby; 12-06-2015 at 10:22 AM.
Jellby is offline   Reply With Quote