Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.76 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. CSS Save image aspect ratio
  2. <img src="big_image.png" style="max-width: 100px; max-height: 100px;" />
  3.        
  4. <div id='container'>
  5.     <ul>
  6.      <li>  
  7.     <img src="http://static.dezeen.com/uploads/2009/01/2-port-house-antwerp-by-zaha-hadid-architects-sqwu-2port-house_antwerp_02.jpg">
  8.         </li>
  9.           <li>  
  10.     <img src="http://static.dezeen.com/uploads/2009/01/2-port-house-antwerp-by-zaha-hadid-architects-sqwu-2port-house_antwerp_02.jpg">
  11.         </li>
  12.           <li>  
  13.     <img src="http://static.dezeen.com/uploads/2009/01/2-port-house-antwerp-by-zaha-hadid-architects-sqwu-2port-house_antwerp_02.jpg">
  14.         </li>
  15.     </ul>
  16. </div>
  17.        
  18. #container{
  19.     max-width:auto;
  20.     max-height: auto;
  21.     background: red;
  22. }
  23.  
  24. img {
  25.     max-width:20%;
  26.     max-height: 20%;
  27. }