code_junkie

How do I force a DIV block to extend to the bottom of a page even if it has no content?

Nov 11th, 2011
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <body>
  2. <form id="form1">
  3. <div id="header">
  4. <a title="Home" href="index.html" />
  5. </div>
  6.  
  7. <div id="menuwrapper">
  8. <div id="menu">
  9. </div>
  10. </div>
  11.  
  12. <div id="content">
  13. </div>
  14.  
  15. body {
  16. font-family: Trebuchet MS, Verdana, MS Sans Serif;
  17. font-size:0.9em;
  18. margin:0;
  19. padding:0;
  20. }
  21.  
  22. div#header
  23. {
  24. width: 100%;
  25. height: 100px;
  26. }
  27. #header a
  28. {
  29. background-position: 100px 30px;
  30. background: transparent url(site-style-images/sitelogo.jpg) no-repeat fixed 100px 30px;
  31. height: 80px;
  32. display: block;
  33. }
  34.  
  35. #header, #menuwrapper {
  36. background-repeat: repeat;
  37. background-image: url(site-style-images/darkblue_background_color.jpg);
  38. }
  39.  
  40. #menu #menuwrapper {
  41. height:25px;
  42. }
  43.  
  44. div#menuwrapper {
  45. width:100%
  46. }
  47.  
  48. #menu, #content {
  49. width:1024px;
  50. margin: 0 auto;
  51. }
  52.  
  53. div#menu {
  54. height: 25px;
  55. background-color:#50657a;
  56. }
  57.  
  58. html,body { height:100%; }
  59.  
  60. #content {
  61. min-height: 600px;
  62. height: auto !important;
  63. height: 600px;
  64. }
  65.  
  66. <div style="min-height: 100%">stuff</div>
  67.  
  68. <html>
  69. <head>
  70. <style type='text/css'>
  71. div {
  72. border: 1px solid #000000;
  73. }
  74. </style>
  75. <script type='text/javascript'>
  76.  
  77. function expandToWindow(element) {
  78. var margin = 10;
  79.  
  80. if (element.style.height < window.innerHeight) {
  81. element.style.height = window.innerHeight - (2 * margin)
  82. }
  83. }
  84.  
  85.  
  86. </script>
  87. </head>
  88. <body onload='expandToWindow(document.getElementById("content"));'>
  89. <div id='content'>Hello World</div>
  90. </body>
  91. </html>
  92.  
  93. height: 100%;
Add Comment
Please, Sign In to add comment