Jump to content

Center footer at bottom of page


peranha

Recommended Posts

Here is the code that I have, but it puts the footer at the left side of the page

 

#footer {
position: absolute;
bottom: 0;
}

 

I change the position to center, and it sets it to the middle of the page.

 

Can you do position: absolute, center;

Link to comment
Share on other sites

Without a link to the page in question I can't be sure this is what you're really looking for, but give this a try:

 

Try placing the footer in a div with an id of "footer" like eddierosenthal suggested, but set the div to have an absolute width. Set the left and right margins to "auto" to center the div.

 

The problem is your footer div has absolute positioning, which overrides the margins and automatically pushes the footer to the left.

 

To fix this, enclose the "footer" div in another div with enclose the "footer" div with an id of "footerwrapper". Give this div the absolute positioning instead.

 

<div id="footerwrapper">
  <div id="footer">
    <p>FOOTER CONTENT GOES HERE</p>
  </div>
</div>

 

/* CSS DOCUMENT */

div#footerwrapper {
position: absolute;
bottom: 0;
width: 99%;
}

div#footer {
width: 700px;
margin: 0 auto;
text-align: center;
}

 

This was tested in Firefox 2.0.0.12 and IE7, and works in both. The CSS code passes W3 validation.

 

The width for the "footerwrapper" div is set to "99%" to prevent the horizontal scroll bar from appearing. There's probably a better fix for this but it's beyond my knowledge.

 

 

Cheers,

Jerry Sidower

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.