Forum Moderators: not2easy

Message Too Old, No Replies

css height problem

page extends too far

         

andre73

12:28 pm on Jan 14, 2004 (gmt 0)

10+ Year Member



Hi I have a div called columnOne that I want to stretch down the entire page from where it is positioned. I can achieve this, however, in mozilla and opera7 the page extends beyond the page so to speak :-0. I get a scrollbar even though there is no content that goes that far down the page. I'm posting the code below so you can see for yourself. Thanks in advance for any help!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" title="currentStyle">
html, body{
color: #000;
background: #fff;
margin: 0px auto;
height:100%;
}
#container{
position:absolute;
top:0px;
left:17px;
width:747px;
height:100%;
background-color:#fff;
}
#topBanner{
position:absolute;
top:0;
left:0;
width:747px;
height:103px;
background-color:transparent;
}
#logo{
position:relative;
top:0px;
left:610px;
width:112px;
height:40px;
}
#columnOne{
position:relative;
width: 186px;
height:100%;
float: left;
top: 117px;
border-right-width: 1px;
border-right-style: solid;
border-right-color: #CCCCCC;
}
#footer{
position:absolute;
background-color:#ADB3BF;
bottom: 0px;
left: 17px;
width:747px;
height: 20px;
vertical-align:middle;
text-align:right;
z-index:100;
}

#footer a{
font:10px Arial, Helvetica, sans-serif;
text-decoration:underline;
color:#726AFF;
margin-right:10px;
}
#footer a:hover{
font:10px Arial, Helvetica, sans-serif;
text-decoration:underline;
color:#FF6633;
margin-right:10px;
}
</style>
</head>

<body>
<div id="container">
<div id="topBanner" style="background: transparent url(images/collageTop.jpg) no-repeat;">
<div id="logo"><img src="images/logoLabel.gif"></div>
</div>
<div id="columnOne">
how do I stretch this div all the way to the bottom so that the border on the right here connects with the footer? Works fine in IE but extends beyond page in mozilla and Opera 7</div>
</div>
<div id="footer"><a href="#">copyright notice</a></div>
</body>
</html>

AWildman

1:07 pm on Jan 14, 2004 (gmt 0)

10+ Year Member



I think it has to do with your top: 117px; and height: 100%; Try removing top: 117px and see if that fixes your problem. Only as a test to verify that the problem is that you have a 100% height on something that is already 117px down on the page which is probably why you have the extra room. If you find this is the answer, you may need to play with your % to get the right height.

andre73

1:23 pm on Jan 14, 2004 (gmt 0)

10+ Year Member



yes! The problem is that it is positioned at 117px from top. I cant really change the % since the next page maybe very much longer than this page and the next page again may contain very little text, so playing with the % wont help me, Or will it? I'm fairly new to this so I really dont know. I want to use the same stylesheet on all pages. Is this a bug in IE since it works like I want it to there?

AWildman

1:45 pm on Jan 14, 2004 (gmt 0)

10+ Year Member



Yeah, IE has a box model bug. Try this: give the div padding-top: 117px; If you don't have a background that will extend into the 117px padding, you should be okay cause the height will then be 100% - padding.

Simmo

1:55 pm on Jan 14, 2004 (gmt 0)

10+ Year Member



Try and see if this example will help you in your quest......

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Simmo's CSS Page Template - Three Column Pixel Perfect - Header &amp; Footer</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
<style type="text/css">
body{
margin: 0;
padding:0;
background:#ffffff;
color: #000000;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}

#leftnav{
position:absolute;
top:62px;
left:0;
width:140px;
z-index:3;
background:#ffffff;}

#rightnav{
position:absolute;
top:62px;
right:0;
width:140px;
z-index:2;
background:#ffffff;}

#containmentblock {
width:100%;
z-index:1;
background:#ffffff;
height:80%;}

#header{
height:60px;
border-bottom:1px solid #408080;
width:100%;
background:#C1C1FF;
margin:0;
}

#content{
margin:0 142px 0 142px;
position:relative;
background:#ffffff;
z-index:5;
border: solid #408080;
border-width:0 1px;
}

#footer {
width:100%;
height:35px;
border: solid #408080;
border-width:1px 0;
background:#C1C1FF;
color: #000000;
margin:0;
}
</style>
</head>
<body>
<!-- header div -->
<div id="header"><h1>Header Content Here</h1></div>
<!-- center column -->
<div id="containmentblock">
<div id="content">
<h3 align="center">Three Column Pixel Perfect with Header &amp;
Footer - MK 1</h3>
In this example the table will stretch to the browser dimensions and the content
will be read first,
<p>The left and right columns are positioned absolutley. And now we have a
header and footer. One problem we first have to overcome is that it's impossible
to get the left and right columns to always match the height of the content
column. If the L&amp;R columns are too short we see the page background
and quite simply it looks awful. If the L&amp;R columns are too long they
overlap the page footer.</p>
<p>To overcome the first problem we enclose the main content div in an outer
div. This unfortunatly has to be the same colour as the L&amp;R columns
which must be the same colour as each other.</p>
<p>The overlap? All I think we can do is to stack the footer higher than the
L&amp;R columns and risk losing content but if you place the footer at the
end of the longest column then it will always display last.</p>
<p>One good thing about this method is that we can set the margins of the
center content div much larger than the width of the left and right columns
and therefore should not need to worry about IE5x PC's stupidity. And it
still gives the appearance of being pixel perfect.</p>
<p>Note also, no need for the box hack as we have built some flexibility into
the template! IMO. Does this hold true in your browser? Please let me know.</p>
<p>Also, one potential problem. If you set position:relative for the #c-block
it completely hides the left and right columns. So just leave it out? In
IE6 yes or else nest ALL the blocks within this div, including the header
div.</p>
</div>
</div>
<!-- end of center column --></div>
<!-- end c-block -->
<div id="footer" align="center"><h4>Footer Div - Copyright Information</h4>
</div>
<!-- left column -->
<div id="leftnav"><br />
<h4 align="center">Left Column</h4>
<p align="center">The left navigation column can be used for navigation links,
search box just about anything that you wish to place in here.</p>
</div>
<!-- end of left column -->
<!-- right column -->
<div id="rightnav"><br />
<h4 align="center">Right Column</h4> <p align="center">More links?</p>
<p align="center"><br />
Advertisements?</p>
<p align="center">plus any other ideas that you may have as this can also be
used for any thing that you wish to place here!</p>
</div>
<!-- end of right column -->
</body>
</html>

andre73

3:19 pm on Jan 14, 2004 (gmt 0)

10+ Year Member



"Yeah, IE has a box model bug. Try this: give the div padding-top: 117px; If you don't have a background that will extend into the 117px padding, you should be okay cause the height will then be 100% - padding. "

This doesnt solve it for me since the borders then run in to and over the image I have at the top.
Will I be forced to resort to tables :-(

Purple Martin

2:29 am on Jan 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use a div inside a div! The outside one is 100% high and has padding at the top. The inside one is 100% of the available space and has the border you want.

andre73

7:40 am on Jan 16, 2004 (gmt 0)

10+ Year Member



When I put it inside a div with 100% height and 117px padding top. I get a scrollbar even though there is no content that needs a scrollbar. The only difference from the previous solution is that I now get it in IE as well :-(

DrDoc

3:59 pm on Jan 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[webmasterworld.com...]
Messages 37 and 38 will give you a good start to understanding the box model.

Also, here's a page that explains it in easy to understand terms:
CSS box model (in layman's terms) [tanfa.co.uk]

php_codeR

3:14 pm on Feb 16, 2004 (gmt 0)



After extensive testing, I found that simply removing the <!DOCTYPE tag removes all problems relating to percentage heights (tested on IE 5+, mozilla "Gecko", and opera). Is there someone else that can substantiate this claim. And does anyone know a work around to fix it.