tags:

views:

2622

answers:

7

I have a header on my page which is just over 100px (111px to be exact) The div below it needs to extend to the bottom of the viewport, as if i had set the bottom to 0px. The problem lies in the fact that i cannot specify top and bottom in ie6 (bug).

I can either specify top: 111px or bottom: 0px, but i still need the height to be correct ie. 100% -111px, according to the size of the viewport.

Can't seem to get expressions working coz that seems to be the solution

Any suggestions?

+1  A: 

I'm guessing that you are trying to get sticky footer

n1313
hmm not exactly that but sort of along those lines. i have a header so i adjusted the css accordingly but the div is too big, still getting set to 100%
moonblade
A: 

Replace

height:100%

with

min-height:100%

in your CSS.

craftsman
A: 
.left

position: absolute;
width: 200px;
top: 111px;
height: 100%

this is almost what i want, however the height is obviously 111px too much. i have tried with margin-top:111px but to no avail

moonblade
A: 

Negative margins of course!

HTML

<div id="header">
    <h1>Header Text</h1>
</div>
<div id="wrapper">
    <div id="content">
     Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur 
     ullamcorper velit aliquam dolor dapibus interdum sed in dolor. Phasellus 
     vel quam et quam congue sodales.
    </div>
</div>

CSS

#header
{
    height: 111px;
    margin-top: 0px;
}
#wrapper
{
    margin-bottom: 0px;
    margin-top: -111px;
    height: 100%;
    position:relative;
    z-index:-1;
}
#content
{
    margin-top: 111px;
    padding: 0.5em;
}
Eric
this just places my div to take up 100% of the page, as before. it is not placed 111px down, meaning it overlaps the header
moonblade
Oops. Post edited
Eric
A: 

hmm i think i'm just going to use javascript. unless anybody has a better idea?

moonblade
used javascript to resolve my issue, thanks to everybody that contributed
moonblade
I think I've got my CSS solution working. All it was missing was a `z-index`.
Eric
"Answer your own question" so the next person can see what you did.
Peter J
A: 

Alternatively, you can just use position:absolute:

#content
{
    position:absolute;
    top: 111px;
    bottom: 0px;
}

However, IE6 doesn't like top and bottom declarations. But web developers don't like IE6.

Eric
thats exactly what i had, and as you have mentioned IE6 doesn't like both used at the same time. I agree with you, but thats how the client wants it. had to write javascript to get it right
moonblade
`top` and `bottom` multiple position declarations don't work on *any* browser
Emile
@Emile: Yes they do, they work in Google Chrome
Eric
@Eric: many apologies! You're right. And I did a quick test without `position: absolute`. My vote's locked in, darnit. Someone upvote this guy and correct my evil ways :)
Emile
+2  A: 

I added the height property to the body and html tags.

HTML:

<body>
<div id="wrapper">
 <div id="header">header</div>
 <div id="content">content</div>
</div>

CSS:

html, body
{
    height: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
}
#wrapper
{
    height: 100%;
    min-height: 100%;
}
#header
{
    height: 111px;
}
ranonE