code_junkie

Setting a div's height in HTML with CSS

Nov 10th, 2011
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. <html> <body> <style type="text/css"> .rightfloat { color: red; background-color: #BBBBBB; float: right; width: 200px; } .left { font-size: 20pt; } .separator { clear: both; width: 100%; border-top: 1px solid black; } </style> <div class="separator"> <div class="rightfloat"> Some really short content. </div> <div class="left"> Some really really really really really really really really really really big content </div> </div> <div class="separator"> <div class="rightfloat"> Some more short content. </div> <div class="left"> Some really really really really really really really really really really big content </div> </div> </body> </html>
  2.  
  3. body
  4. -> header (big blue banner)
  5. -> headerNav (green bar at the top)
  6. -> breadcrumbs (invisible at the moment)
  7. -> page
  8. -> navigation (floats to the right)
  9. -> content (main content)
  10. -> clear (the quote at the bottom)
  11. -> footerNav (the green bar at the bottom)
  12. -> clear (empty but still does something)
  13. -> footer (blue thing at the bottom)
  14.  
  15. <html> <head> <style> html,body { height: 100% } #left { float: left; width: 25%; height: 100% } #right { width: 75%; height: 100% } </style> </head> <body> <div id="left"> Content </div> <div id="right"> Content </div> </body></html>
  16.  
  17. <div class="row">
  18. <div class="right-column">Right column content</div>
  19. <div class="left-column">Left column content</div>
  20. </div>
  21. <div class="row">
  22. <div class="right-column">Right column content</div>
  23. <div class="left-column">Left column content</div>
  24. </div>
  25.  
  26. html,
  27. body {
  28. height:100%;
  29. }
  30.  
  31. div.row {
  32. width:100%; /* Clear internal floats in IE */
  33. overflow:hidden; /* Clear internal floats */
  34. }
  35.  
  36. div.right-column,
  37. div.left-column {
  38. padding-bottom:1000em; /* } Balance the heights of the columns */
  39. margin-bottom:-1000em; /* } */
  40. }
  41.  
  42. div.right-column {
  43. width:20%;
  44. float:right;
  45. }
  46.  
  47. div.left-column {
  48. width:79%;
  49. float:left;
  50. }
  51.  
  52. <html>
  53. <body>
  54. <style type="text/css">
  55. .rightfloat
  56. {
  57. color: red;
  58. background-color: #BBBBBB;
  59. float: right;
  60. width: 200px;
  61. }
  62.  
  63. .left {
  64. font-size: 20pt;
  65. }
  66.  
  67. .separator {
  68. clear: both;
  69. width: 100%;
  70. border-top: 1px solid black;
  71. }
  72. </style>
  73.  
  74. var leftcol = $("#leftcolumn");
  75. var rightcol = $("#rightcolumn");
  76. var leftcol_height = leftcol.height();
  77. var rightcol_height = rightcol.height();
  78.  
  79. if (leftcol_height > rightcol_height)
  80. rightcol.height(leftcol_height);
  81. else
  82. leftcol.height(rightcol_height);
Add Comment
Please, Sign In to add comment