Guest User

Untitled

a guest
Sep 18th, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. Middle div with 100% in CSS? [closed]
  2. <body>
  3. <div id="container">
  4. <div id="header">
  5. </div>
  6. <div id="content">
  7. </div>
  8. <div id="footer">
  9. </div>
  10. </div>
  11. </body>
  12.  
  13. html, body {
  14. margin: 0;
  15. padding: 0;
  16. border:1px;
  17. vertical-align:top;
  18. font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
  19. font-size:14px;
  20. color:#333;
  21. height: 100%;
  22. }
  23. #container {
  24. height: 100%;
  25. width: 100%;
  26. }
  27. #header {
  28. height: 100px;
  29. width: 100%;
  30. background: #069;
  31. }
  32. #content {
  33. height: 100%;
  34. width: 100%;
  35. background: #F60;
  36. }
  37. #footer {
  38. height: 75px;
  39. width: 100%;
  40. background: #060;
  41. }
  42.  
  43. 30px
  44. 100% (500px)
  45. 30px
  46.  
  47. 30px
  48. 100% (460px)
  49. 30px
  50.  
  51. * { margin: 0; padding: 0 }
  52. html, body {
  53. margin: 0;
  54. padding: 0;
  55. vertical-align:top;
  56. font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
  57. font-size:14px;
  58. color:#333;
  59. height: 100%;
  60. border: 0;
  61. }
  62. #header
  63. {
  64. height: 100px;
  65. background:#C60;
  66. }
  67.  
  68. #container
  69. {
  70. min-height: 100%;
  71. height: auto !important; /*Cause footer to stick to bottom in IE 6*/
  72. height: 100%;
  73. margin: 0 auto -100px; /*Allow for footer height*/
  74. vertical-align:bottom;
  75. background:#096;
  76. }
  77.  
  78. #footer
  79. {
  80. height: 100px; /*Push must be same height as Footer */
  81. background:#C60;
  82. }
  83.  
  84. <body>
  85. <div id="container">
  86. <div id="header"> </div>
  87. <div id="content"> </div>
  88. </div>
  89. <div id="footer"> </div>
  90. </body>
  91.  
  92. <body>
  93. <div id="header">
  94. </div>
  95. <div id="content">
  96. </div>
  97. <div id="footer">
  98. </div>
  99. </body>
  100.  
  101. #header {
  102. position:absolute;
  103. top:0px;
  104. left:0px;
  105. right:0px;
  106. height: 100px;
  107. background: #069;
  108. }
  109. #content {
  110. position:absolute;
  111. top: 100px;
  112. bottom: 75px;
  113. left:0px;
  114. right:0px;
  115. background: #F60;
  116. }
  117. #footer {
  118. position:absolute;
  119. bottom: 0px;
  120. height: 75px;
  121. left:0px;
  122. right:0px;
  123. width: 100%;
  124. background: #060;
  125. }
Add Comment
Please, Sign In to add comment