views:

28

answers:

3

I have a div called "content" which I wish to at least take up the entire height of a window.

So what I did was this:

body
{
   min-height:100%;
   height:auto !important;

   /* The following probably aren't relevant but I'll include them just in case */
   min-width:600px;
   color: #fff;
   font-family:'lucida grande',verdana,helvetica,arial,sans-serif;
   font-size:90%;
   margin: 0;
}
div#content
{
   min-height:100%;

   /* The following probably aren't relevant but I'll include them just in case */
   clear: both;
   color: #333;
   padding: 10px 20px 40px 20px;
   position:relative;
   background:url(/img/strawberry.png) right bottom no-repeat;
}

Using firebug, I verified that indeed is now taking up the entire page (even when there's no content on the page. Just as I wanted)

However the problem is, content is not taking up the entire height of , but instead being only as large as its internal contents.

EDIT: Seems to work in chrome 7.0.517.41, but not in firefox 3.6.10 (problem seems to occur in all versions of firefox 3.6.x and probably previous versions as well).

+1  A: 

You could try setting an explicit height as well as a min-height:

min-height:100%;
height:100%;

Don't know for sure if it'll work, but something inside says it might.

Kyle Sevenoaks
Problem with that though is if the content of the page DOES get larger than one window, then the div wont scale. =[
Razor Storm
Use height instead of min-height on body. If the div gets bigger, it should overflow and get displayed correctly (works in firefox, chrome, ie for me).
bazmegakapa
Awesome it solved it. I'm not sure which one to mark as the right answer since both of you guys contributed one part to the final solution: (use html AND body, and also use height along with min-height). Voted up
Razor Storm
Glad to help :)
Kyle Sevenoaks
+1  A: 

I've already solved a similar problem with

html,body {
    padding:0;
    margin:0;
    height:100%;
    min-height:100%;
}

It seems <html> is sometimes taken into account to calculate height.

MatTheCat
Tried it, no effect on ff 3.6.10. =[
Razor Storm
Actually nvm it worked, it was the height:auto!important; that was killing it. i wonder why it didn't affect chrome though.
Razor Storm
The only thing I know is height calculation is VERY hazardous depending on the browser... =/
MatTheCat
A: 
body, html {
    padding:0;
    margin:0;
    height:100%;
    min-height:100%;
}
div#content
{
   min-height:100%;
   height: 100%;
}

This works for sure...

Badr Hari