PDA

View Full Version : Centering a website



BlackEros
17 Mar 2009, 07:14 PM
Can someone tell me how I can center my site. It is driving me crazy!!!!!!!!

www.uscanautodealer.com

Thanks in advance.

I have tried all of the below methods/links to no avail


Get in to CSS- it's really simple and easy to use.
There are 3 methods that work well for page centering...


// CSS centering method 1
div# container {
margin-left: auto;
margin-right: auto;
width:168px; //or whatever your element width is
}

// CSS centering method 2
body {
text-align:center;
}

// CSS centering method 3 (combo of 1 and 2)
body {
text-align:center;
}
#container {
margin-left: auto;
margin-right: auto;
border: 1px solid red
width: 170; // element width must take account of any padding and borders
// all text must have it's own align value when the body
// align is centered so add this next line too-
text-align: left;
}
// CSS centering method 4 (Hicks method)
#container {
background: #ffc url(yourImage.jpg) repeat-y center;
position: absolute;
left: 50%;
width: 168px; // your elements width
margin-left: -84px; // negative value equal to half your elements width
}
http://www.webmaster-talk.com/css-forum/118081-how-to-center-your-website.html http://davidwalsh.name/horizontally-center-website-structure-css