View Full Version : Centering a css layout


StarryIlove
09-13-2004, 08:53 AM
I'm designing a new web page and want to make it centered in the page so it will suit all resolutions. Is it possible to center a css layout? If so how do I do it?

Thanks,

Starry :star:

pb&j
09-13-2004, 01:26 PM
depends on your layout.
if you are using "absolute" positioning, then that will have to be taken out.
after that, relative positioning and/or centering can be put in.

dexus
09-13-2004, 02:48 PM
<style type="text/css">
div#container {position:relative;margin:0px auto;width:760px;}
</style>

[...]

<div id="container">text</div>

this works in IE but also in mozilla and netscape.

dexus

StarryIlove
09-16-2004, 10:59 AM
So I add that code where? in my head and the second in my body

Monkey Bizzle
09-16-2004, 04:07 PM
yes, but keep in mind that you only need one set of <style> tags. if you already are using CSS for your body and links or whatever, then you don't need to include the <style> tags from the code above, just the


div#container {position:relative;margin :0px auto;width:760px;}

StarryIlove
09-16-2004, 06:02 PM
It doesn't seem to be working. My site is still aligned left

dexus
09-16-2004, 07:30 PM
add this:
body {text-align:center;}

put it just above the div#container {po...

dexus