100% scale background image (doesn\'t preserve aspect ratio)

/ Published in: CSS
Save to your folder(s)

Note that this approach DOESN'T maintain the image's aspect ratio. For a pure CSS technique that does that you need a CSS3 approach.

Copy this code and paste it in your HTML
  1. img.bg {
  2. height: auto;
  3. left: 0;
  4. min-height: 100%;
  5. min-width: 1024px; /*adjust this to match image width */
  6. position: fixed;
  7. top: 0;
  8. width: 100%;
  9. z-index: -1;
  10. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.