Click to See Complete Forum and Search --> : align my site to the center


chris9902
11-09-2003, 03:11 PM
I made a site layout using DIV tags.

i use the absolute and then added left and top apps to line it all up.

now i want to center my site.

how do i do that?

pyro
11-09-2003, 06:25 PM
Put a container div around it all, and use margin: auto; for complaint browsers, and text-align: center; (around the parent of you container tag -- probably the <body> tag) for IE 5.

bobmurphy
11-11-2003, 07:02 PM
i got a page to centre in both planes ( X&Y) by putting everything in a div and giving the div the following style

div {position:absolute; height:420px; width:770px; top:50%; left:50%; margin:-210px 0px 0px -385px}

those dimensions work for anything from 600*800 up to pretty big - but it goes nuts in version 4 browsers and opera 5.02 - so i used the php function -> preg_match to provide opera with a different style


there are also some pretty good pages on the net that major on centering -- it's worthwhile doing a search

you can see the effect on my site ( still under development ) at www.oneweekofdays.com/biog