Maintaining Aspect Ratio with 100% Width & Height (Cropping Overflow in CSS)
<p>I'm working on full-screen background slideshow.</p>

<p>My question is: How can I set an image to take up the full screen and maintain aspect ratio? </p>

<p>Min-height and min-width work, but do not keep the aspect ratio when both are set. I want the image cropped with the full coverage of the container.</p>

<p><a href="http://i.stack.imgur.com/KdpnZ.gif" rel="nofollow">Diagram of Problem</a></p>

<p>I believe I need to have one dimension fixed, and the other to auto; given that the image dimensions and view-port dimensions are variable, I'm thinking I would need at least 2 sets of CSS rules, and javascript to calculate which one should be used. Is there a simpler way to do this?</p>

<p>I've drawn up a diagram illustrating my problem. The dark colors are the original images. The median colors are the desired effect. The lighter colors are the desired overflow from the scaled up image. </p>

<p>I'm working on a Ken-Burns effect full-screen background. I know I have to worry about transitions, but I'm hoping that I can handle that after.<br /></p>

<p>Tutorial for Ken Burns Effect:<br />
<a href="http://cssmojo.com/ken-burns-effect/" rel="nofollow">http://cssmojo.com/ken-burns-effect/</a><br /></p>

<p><strong>Solved:</strong> Thanks Maju for introducing me to background cover. Changing the images to divs and changing the javascript + css on the Ken Burns code from images to divs worked well. The script changes the element class, so you have to use Maju's CSS another way or change the script.</p>