PDA

View Full Version : centering everything?



freshfan
Jan 27th, 2010, 09:55 PM
I have my website set up, so there each item has a specific css position [i.e. XX pixels from left, XX pixels from top].

Now my whole site is aligned to the left side.

IS there a way to center everything, and still keep the position of the images the same relative to eachother?

so basically, just take the design I have, and center the whole things as a whole.

like make a table or something, and center that?

Excavator
Jan 27th, 2010, 10:00 PM
Hello freshfan,
You can wrap your whole site in a containing div, give it a width and position:relative; and center that with left/right margins set to auto.

You will probably(?) have to re-calculate the positioning of everything though... maybe not though.

freshfan
Jan 27th, 2010, 10:07 PM
thanks. my site has over 20 div's already though. for a containing div, do I just set up another, and put it around the rest?

Excavator
Jan 27th, 2010, 11:52 PM
Yes, like this:

<div id="wrapper">
...
your site
...
<!--end wrapper--></div>
and
#wrapper {
width: ___px;
margin: 0 auto;
position: relative;
}

That bit of CSS will center it but, like I said, the ap elements you already have may need adjusted.