html - How do you stretch an image to fill a while keeping the image's aspect-ratio? - Stack Overflo
Since you don't know the aspect ratio, you'll have to use some scripting. Here is how I would do it with jQuery (demo): CSS.container { width: 40%; height: 40%; background: #444; margin: 0 auto; } .container img.wide { max-width: 100%; max-height: 100 ......