Forum Moderators: not2easy

Message Too Old, No Replies

background color at 100% in all browsers

BG color is cut off at browser bottom on scroll

         

CSS_Kidd

4:09 pm on Mar 9, 2009 (gmt 0)

10+ Year Member



I have a set up of two divs relitively positions at a min-height of 100% in a body of 100%. I want them to be different colors. however if a browser window is minimized (small not full window) or if the content extends the viewable area, the bg color stops at the 100% of the viewable area and is cut off on the scroll. As of now only my right container shows the bg color completely, but the left is cut off.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
<!--
* {
margin: 0px;
padding: 0px;
}
html, body {
height: 100%;
}
body {
font: 10px Verdana, Arial, Helvetica, sans-serif;
background: #FFFFFF;
}
#header_container {
height: 100px;
width: 800px;
position: absolute;
z-index: 10;
left: 0px;
top: 0px;
background: #FFFFFF;
}
#header_top {
background: #CCCCFF;
height: 79px;
}
#header_bottom {
background: #FFFFFF repeat-x left top;
height: 20px;
border-bottom: 1px solid #000000;
}
#left_container {
background: #cccccc;
width: 150px;
min-height:100%;
position: relative;
left: 0px;
top: 0px;
clear: left;
float: left;
}
#menu_box {
padding-top: 110px;
border: 1px solid #000000;
}
#right_container {
width: 649px;
border-left: 1px solid #000000;
min-height:100%;
left: 0px;
top: 0px;
background: #999999;
float:left;
}
#right_content {
padding: 110px 10px 10px;
}
.clear_float {
font-family: 0;
line-height: 0px;
}
-->
</style>
</head>

<body>
<div id="header_container">
<div id="header_top">Content for id "header_container" Goes Here</div>
<div id="header_bottom"></div>
</div>

<div id="left_container">
<div id="menu_box">Content for id "left_container" Goes Here</div>
</div>
<div id="right_container">
<div id="right_content">Content for id "right_container" Goes Here
<p>Lorem ipsum ...
LOTS OF CONTENT TO MAKE THE PAGE EXTEND AND SCROLL
</p>

<br class="clear_float" />
</div>
</div>
</body>
</html>

swa66

12:21 am on Mar 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



as soon as you set height: 100% on body you've lost, as it won't go larger anymore. I think the trick to solve this lies in setting a height:100% on html, a min-height:100% on your body and let you columns be their own height. Use some clearing on them to force the height of the body to stretch should only one of your floated columns be larger than the height of the viewport.

That makes your backgrounds on the floats not work as columns, so you need to switch there to faking the columns on the background of the body itself.

If you need it with fluid width, search for "flexy-floats", you'll find a technique promoted by SuzyUK ...