Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Css Footer problem

Status
Not open for further replies.

gokeeffe

Programmer
Jan 11, 2005
170
IE
Hi,

I have tried to use the following code but the footer will not stay at the end of the screen no matter what I try.

ie. the footer scrolls up and does not stay at the end

Can anyone see why.

I hope the code isn't too confusing.

I am using a three column layout with a header at the top.

Would really like to get this to work.


/************************ Start of CSS file ********************************/
html, body, #contents {
min-height:100%;
width:100%;
height:100%;
}

html>body, html>body #contents{
height:auto;
}

#contents{
position:absolute;
top:0;
left:0;
}

#footer{
position:absolute;
bottom:0;
width:100%;
border-top:1px solid #333333;
background-color: #000033;
color: #ffffff;
font-size:70%;
}


#footer p{
margin: 0.5em 0 1em 2em;
padding: 0;
}
/****************************** End of CSS file *******************************/
 
Sorry,

I mean when the content in the center is long enough, it works fine but when the content is not when you scroll down the footer detaches from the end of the browser.

I hope you know what I mean

 
I got this code from a book called 101 essential css tip and tricks (sitepoint) and they said to use absolute positioning, do you know of any other way to do this.

Tks

Graham
 
If you want the footer fixed at the bottom of the browser window, then use absolute positioning. But as you have found if you do so and your content extends beyond the bottom of the window then your footer isn't at the foot of your content.

Why not just put the footer at the end of the content?

I can't say I've ever run into this really since I don't design pages to be fixed sizes if I can possibly help it. So my footers go under my content. The browser is merely a "view portal" that people look through to see the pages, it can be whatever size the user wants, it's none of my business.

Foamcow Heavy Industries - Web design and ranting
Toccoa Games - Day of Defeat gaming community
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
"I'm making time
 
I think it is time to get a better book. I cannot see any columns in the code you posted, but I guess it could be because you omitted some of the code. Anyway, you're using only absolute positioning, meaning that no elements on your page interact with each other. Absolute positioned elements are taken out of the flow and are invisible to other elements. Thus no element on the page knows where the other one ends. As such, you can position things around the page, but don't look for interaction. If you want that, use normal document flow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top