Forum Moderators: not2easy

Message Too Old, No Replies

Help with css footer

         

intrik

6:47 pm on Jul 5, 2004 (gmt 0)

10+ Year Member



Hey there guys, I've found some usefull info from browsing here, but unfortunately I have my own question about footers.

I want to be able to do this:
-Website 100% height
-If short content (dont have to scroll, footer is at the bottom of the viewable window) <-- 100% height
-If long content (if you have to scroll, the footer is below the content)

I used to be able to do this with tables, something like
<table style="height: 100%">
<tr>
<td style="height: 100%">
content
</td>
</tr>
<tr>
<td style="height: 20px">
footer
</td>
</tr>
</table>

That way the footer will be down the bottom no matter what.

I understand that for 100% height you must have

body, html {
height: 100%
}

in your css. I want it to work in IE / firefox / opera.

I think i found a way to make it work a few days ago, but it only worked in IE. Does anybody know how to do this with just css?

Using something like this does not work:


<html>
<head>
<style type="text/css">
<!--
body. html {
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
margin-bottom: 0px;
height: 100%
}

#height {
height: 100%
}

#footer {
height: 20px;
position: absolute;
bottom: 0px;
top: auto
}
-->
</style>
</head>
<body>
<div id="height">hghg
<div id="footer">
footer
</div>
</div>
</body>
</html>

Because once the content goes past the original view of the window, the footer sticks to the bottom of the initial "100% view" of the browser.

I want it to be at the bottom if the content is small (like in that example) but still at the bottom once the content goes past the initial view and you have to scroll.

Any help would be great.

fmaz

7:29 pm on Jul 5, 2004 (gmt 0)

10+ Year Member



Same problem here ... any solution/example?
(without using table)

createErrorMsg

8:11 pm on Jul 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is the second time today I've seen a question regarding a site that has "100% height" and I must admit, I am baffled. What does that mean, 100% height?

In my book, 100% equals the height of all my content. Can you describe a little more exactly what effect you're trying to produce? Are you trying to get your footer to "stick" to the bottom of the browser window?

fmaz

8:25 pm on Jul 5, 2004 (gmt 0)

10+ Year Member



Me: Yes ...
I want the footer to be "stiky" to the bottom of the windows OR, if the page need to scroll, at the bottom of the page.

height=100% for me mean: document.height (in javascript)

createErrorMsg

10:05 pm on Jul 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only way I can think to accomplish this, short of using JS to read screen resolution and browser window size, is to wrap a container div around your whole page, give it a position: relative, then give your footer...

position: absolute;
bottom: 0;
left: 0;

Make sure the container <div> has a width of 100% (or the max width of your content area), and don't forget to give it a position: relative, as you cannot absolutely position anything in it without.

I think you would also need to ditch the body 100% thing, as I do not believe that accomplishes anything.

<edit>Thinking about it, I don't think this will accomplish your goal, as it does not force the container <div> to be the full height of the window if the content isn't there. You can try the position absolute; bottom: 0; left: 0; thing WITHOUT the container div (which will position them in relation to the browser window) but I'm not 100% sure what this will do when the content scrolls.</edit>

fmaz

12:01 am on Jul 6, 2004 (gmt 0)

10+ Year Member



CSS3 suggestion:

a bottom and a right property:

bottom=0px;

hehe :)

fmaz

2:31 am on Jul 6, 2004 (gmt 0)

10+ Year Member



So there is no way to make a footer like this to stick to the bottom of the page?

[pro2.ath.cx...]

?
Or at least, not to "stick" but to be AFTER the Div of the page text (wich is invisible on the page I gave you)

intrik

6:01 am on Jul 6, 2004 (gmt 0)

10+ Year Member



You need body, html height 100% because like somebody said 100%height means the height of the container to reach the height of the content.

if you put it in body and html 100% means the height of the viewable area.

DrDoc

6:10 am on Jul 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



body. html

I hope that dot is a typo, since it needs to be a comma for it to work :)

intrik

6:24 am on Jul 6, 2004 (gmt 0)

10+ Year Member



It doesnt matter, the test doc is in quirks mode. It's only when you put a html 4.01 or xhtml1.0 doctype that you need body, html there.