[web] CSS Question.

Started by
4 comments, last by Sander 18 years, 10 months ago
Is there a way to line up a div block to the bottom of another div block? The idea is a page container that has a fixed min-height and then to always align the footer to the bottom. I can do it now by filling up the vertical space with div blocks that have % heights that total 100% but this tends to break other things. Tim.
Advertisement
Maybe something like

bottom : 0em;

or

vertical-align : bottom;
There are several ways to stick a div to the bottom of another div. Unless I misunderstood what you want, the easiest method in this case is to put two divs inside the page container div, and assign the min-height to the first contained div.
_____________________________________|  Page container div.              ||   Has no height specification.    || _________________________________ || | Everything except the footer  | || | goes here.                    | || | Specify a min-height for this | || | div only                      | || |_______________________________| || _________________________________ || | Footer                        | || |_______________________________| ||___________________________________|

P.S. I'm not sure what you mean by page container, but unless it has a border or special positioning or something, the page container div is redundant in my example.
You could have a block with a minimum height of 100% with a bottom-margin greater than the height of the footer, followed by the footer with a negative top margin.

Be aware that Internet Exploder does not support the min-height property, though it should degrade nicely.
Free Mac Mini (I know, I'm a tool)
This article should get you started [smile]

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

Wrap one div wrap around both, and apply vertical-align:bottom; to both the divs you want to line up.
spraff.net: don't laugh, I'm still just starting...

This topic is closed to new replies.

Advertisement