Jump to content


Photo

CSS Footer alignment


  • Please log in to reply
3 replies to this topic

#1 hobulus

hobulus

    Jedi In Training

  • Members
  • PipPip
  • 346 posts
  • Location:United Kingdom

Posted 19 September 2007 - 04:46 AM

Hi All,

Its been a long while since i have been on here, it all looks so good still these days :)

I am having a problem with a CSS layout of mine...I hope someone can shed some ligh on it for me.
I have a footer that won't align to the centre of the page. It is wrapped in a container that is 100% of the page. no tect alignment at all.
The body is Text-aligned: center so it should inherit the alignment from that. Can someone please help me out, its driving me nuts! :)

The CSS code is below:

html,body{margin:0;padding:0}
body{font: 76% arial,sans-serif;text-align:center; background-image:url(../site_images/page_bg.gif); background-repeat:repeat-x}

p{margin:0 10px 10px}
a{display:block;color: #981793;padding:10px}

div#header{width:779px; height:156px; margin:0; background-color:#0066FF;}
  
div#container{text-align:left}
div#content p{line-height:1.4}

div#container{width:779px;margin:0 auto}
div#content{float:left; width:628px; height: 600px; background-color:#FFFFFF;}
div#sidelinks{float:left; width:151px; height: 600px; background-color:#003366;}

div#footercontainer{clear:both; text-align:center; background-image:url(../site_images/footer_bg.jpg); width:100%; height:143px;}

div#footer{clear:both; background-color:#00FFFF; width:779px; height:143px;}
div#footer p{margin:0;padding:5px 10px}


#2 tomos

tomos

    Young Padawan

  • Members
  • Pip
  • 58 posts

Posted 19 September 2007 - 09:56 AM

try this:

div#footer {
		 clear:both; 
		 background-color:#00FFFF; 
		 width:779px; 
		 height:143px;
		 margin: 0 auto; /*This will float the footer in the middle without any padding on the top or bottom*/
}

div#footer p {
		 margin:0;
		 padding:5px 10px;
		 /*text-align: center;*/	/*If the text doesnt aling to the center of the footer with the edit I added to the footer ID, then uncomment the text-align: center that I commented out on the paragraph settings for the footer*/

Edited by tomos, 19 September 2007 - 10:06 AM.


#3 _*Creative Insanity_*

_*Creative Insanity_*
  • Guests

Posted 19 September 2007 - 10:58 AM

Just auto the margins in the wrapper (of what you called your controlling div) and place the footer before the closing wrapper div like.
#wrapper{
 margin: 0px auto;
 width: 779px;
}
This will auto the left and right margins and the xhtml like.
<div id="wrapper">
other code like panels and content etc.
<div id="footer"></div>
</div>
This will center your footer.

Edited by Creative Insanity, 19 September 2007 - 11:02 AM.


#4 hobulus

hobulus

    Jedi In Training

  • Members
  • PipPip
  • 346 posts
  • Location:United Kingdom

Posted 19 September 2007 - 11:02 AM

Thanks guys! Worked a treat. Very Much Appreciated! :biggrin:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users