Fullsize background image


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



Copy this code and paste it in your HTML
  1. /* css */
  2. #bg {
  3. position:fixed;
  4. top:-50%;
  5. left:-50%;
  6. width:200%;
  7. height:200%;
  8. }
  9. #bg img {
  10. position:absolute;
  11. top:0;
  12. left:0;
  13. right:0;
  14. bottom:0;
  15. margin:auto;
  16. min-width:50%;
  17. min-height:50%;
  18. }
  19.  
  20. /* html */
  21. <div id="bg">
  22. <img src="images/background.jpg" alt="Background Image" />
  23. </div>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.