Link to home
Start Free TrialLog in
Avatar of Trel
Trel

asked on

How can I extend a div to the bottom of the page?

Take for instance this layout: http://www.krahs-emag.com/test06d2.php

The white line is a left border on a containing div, if my content does not reach the end of the page, the containing div does not either.

How can I make that div extend to the bottom of the page if the content does not make it reach there?

I want to add that I need this to stay XHTML strict.
Avatar of harshgrover
harshgrover

look at the following two samples of code.

1) This is something similar to what you have. The div spans just one column

***************
<html>
<div style="background:red" >hello world</div>
<body>
</body>
</html>
*******************************
2) This is the modified code, to have a fixed height

************************************
<html>
<div style="background:red;height:80%" >hello world</div>
<body>
</body>
</html>
*************************************
Just a word of caution though.
if you set the height of the div defined by the class "content-box", you would not be able to get the desired effect.

the key is to understand, that the percentages work relative to the parent div. so you would need to set this percentage in the class "right-column" and also in "content-box"

Lemee know if you need any clarifications

~Gary
Avatar of Trel

ASKER

I'm not sure I understand that.
Also, wouldn't that cause a problem if the content inside exceeded the 100% of the page and needed to cause a scroll bar?
Avatar of Trel

ASKER

Wait, another quesition, I'm trying to set the wrap div to do it, not the inner left and right ones. That one is

<body>
<div class="wrap">
rest of the page
</div>
</body>

If I set the wrap class to a height:100%; there is no change at all.
to answer your second question, no it wont cause a problem. the height percentage attribute is overridden if the content is more than the allowed percentage. it automatically extends itself.

hopefully the following two examples should illustrate better on what i mean.
1)
********************
<html>
<div>
    <div style="background:red;height:80%" >hello world</div>
</div>
<body>
</body>
</html>
********************

2)
********************
<html>
<div style="background:blue;height:100%">
    <div style="background:red;height:80%" >hello world</div>
</div>
<body>
</body>
</html>
********************

In the first example, the div does not span 80% of the page. Its height is set to 80% of its parent div. Since there is no height attribute set for the parent div, the child div is still as high as its parent div.

now consider the second piece of code.
The first div has the height set to 100%. so it spans the entire page.
The child div has the height set to 80%, so it spans 80% of the parent div's height.

To summarize, if you have nested div's as in the examples above, all the position elements, namely 'position', 'top', 'left', 'height', 'width' etc, they are all with respect to their parent div tags.

Hope this helps
yup...i saw your page structure. you would need to set the height:100%  to your right-column, then to your content-wrapper-b, and then to your content-box

Avatar of Trel

ASKER

It made absolutely no difference :(

Without the height:100% : http://www.krahs-emag.com/test06d3.php
With the height:100% : http://www.krahs-emag.com/test06d4.php

no visible difference
ASKER CERTIFIED SOLUTION
Avatar of Daydreams
Daydreams

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
but you did not make the complete changes...after changing the class wrap to have height:100%, you also need to have height:100% in the class ".right-column"

right now, it is as below:

.right-column
{
      width: 80%;
      float: left;

}

~Gary
Avatar of Trel

ASKER

@Daydreams, I'll try that now, will that invalidate my CSS?
@harshgrover, it's the second url that I modified: http://www.krahs-emag.com/test06d4.php
yup...i looked at the second url. and it did not have the height:100% set. it only had the width set
Avatar of Trel

ASKER

@harshgrover, I was looking at my offline copy, sorry, it still didn't make a difference.

@daydreams, that worked, what exactly is the need for the IE conditional, it's working fine in IE6
Trel, for the conditional comments, IE 6.0 and lower does not support min-height, (although IE7 may support it; I haven't tested). However, its treatment of the height property — where it respects your height until you add more content than the height can accommodate, at which point it expands the height regardless of your desired value — is exactly how min-height is supposed to function.

More info on conditional comments:

http://alastairc.ac/2006/05/conditional-comments-in-css/
Avatar of Trel

ASKER

Thanks, it was working on one file and not the other, the one it was working with had extra padding on the bottom I forgot to remove so it did extend, on the one that wasn't working, that IE thing fixed it, thanks :)