title: How to scale a background image without losing proportions
body: <p>I want to create a web page background image that fills the entire background, without distorting the image and changing it's proportions. </p>
  
  <p>You can see a great implementation of this on LaunchRock's pages, and on their homepage, <a href="http://launchrock.com/" rel="nofollow noreferrer">for example</a>.</p>
  
  <p>I saw <a href="https://stackoverflow.com/questions/1150163/stretch-and-scale-a-css-image-background-with-css-only">this question on StackOverflow</a> however if you play around with what that produces you'll see that the background image is 100% height and 100% width which means that the original proportions of the photo are not maintained and the image is stretched.</p>
  
  <p>Notice in the LaunchRock example that if you resize your browser window the image grows proportionally and always fills the entire window (no matter what size window or background image they use).</p>
  
  <p>If the browser window is not wide enough it crops the sides of the background image (keeping the image centered and cropping the left and right sides) and if the window is not high enough it crops the bottom part of the background image. </p>
  
  <p>No matter what size the browser window is, the image height/width ratio is maintained and the entire background is filled.</p>
  
  <p>I'm guess this can't be done with pure CSS, some JavaScript may be needed.
  Any ideas?</p>
  
  <p>Thanks</p>