Advertisement
PayneLess_Designs

100% Background Image - CSS 3

Jun 20th, 2011
707
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.90 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html><head>
  3. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  4. <title>100% Background Image - CSS 3</title>
  5.  
  6. <meta name="created" content="Sat, 27 Nov 2010 19:44:02 GMT">
  7. <meta name="description" content="">
  8. <meta name="keywords" content="">
  9. <meta name="author" content="PayneLess Designs">
  10. <meta name="copyright" content="Jan 2004 to present.">
  11. <meta name="robots" content="all">
  12. <meta name="revisit-after" content="60 days">
  13.    
  14. <style type="text/css">
  15. * { margin: 0; padding: 0; border: 0; }
  16.  
  17. div#org-img {
  18. position: relative;
  19. z-index: 1;
  20. width: 256px;
  21. height: 256px;
  22. /* background: url(images/rabbit-sm.jpg) no-repeat center scroll; */
  23. }
  24.  
  25. div#org-img img {
  26. border: 1em ridge #f00;
  27. }
  28.  
  29. div#org-img p, h1 {
  30. text-align: center;
  31. color: #fff;
  32. }
  33.  
  34. #bg {
  35. position: fixed;
  36. top: -50%;
  37. left: -50%;
  38. width: 200%;
  39. height: 200%;
  40. }
  41.  
  42. #bg img {
  43. position: absolute;
  44. top: 0;
  45. left: 0;
  46. right: 0;
  47. bottom: 0;
  48. margin: auto;
  49. min-width: 50%;
  50. min-height: 50%;
  51. z-index: -1;
  52. }
  53.  
  54. pre {
  55. position: relative;
  56. margin-top: 5%;
  57. margin-left: 2%;
  58. visibility: hidden;
  59. }
  60. </style>
  61.  
  62. <!--[if IE]>
  63. <link rel="stylesheet" type="text/css" href="site_css/css_2010_iestyle.css">
  64. <![endif]-->
  65. </head>
  66. <body>
  67. <h1>100% Background Image - CSS 3</h1>
  68. <div id="org-img"><img style="width:256px; height: 256px;" src="http://i160.photobucket.com/albums/t184/PayneLess_Designs/Backgrounds/bg_24.jpg" alt=""><p>Original image size:<br>256px by 256px.</p></div>
  69.  
  70. <div id="bg"><img src="http://i160.photobucket.com/albums/t184/PayneLess_Designs/Backgrounds/bg_24.jpg" alt="">
  71. <pre>
  72. Works in:
  73.  
  74.     * Opera (any version) and IE both fail in the same way (wrongly positioned, not sure why)
  75.     * Safari / Chrome / Firefox (didn’t test very far back, but recent versions are fine)
  76.     * IE 8+
  77. </pre>
  78. </div>
  79. </body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement