Forum Moderators: open

Message Too Old, No Replies

Aligning site to the center

         

orion_rus

2:06 pm on Nov 17, 2004 (gmt 0)

10+ Year Member



Hello world,
i have a site in 1024x768 resolution, but if browser have more than it, i need to make all content center aligned, can u help me with it?

BonRouge

2:28 pm on Nov 17, 2004 (gmt 0)

10+ Year Member



You can wrap the contents of your page in a div called say, #wrapper and then set a width and margins for this.
Many people actually design for 800x600 browsers.
You could do something like this (maybe) :


#wrapper {width:780px; margin:0 auto;}

That's the general idea anyway.

webboy1

3:26 pm on Nov 17, 2004 (gmt 0)

10+ Year Member



A quick way to centre all your content is to use a tables.

We have to do this in a few of our sites, and it is XHTML 1.0 valid.

Simply place everything on your page within a 1 column x 1 row table. Give this table a width of 100% and align everything in it to the centre.

That way, not matter what size of browser the site is viewed in - it will be in the middle. Obviously in your case, having created the site so large, users will have difficulty seeing the content in 800x600 browsers.

Hope this helps!

badams1

3:33 pm on Nov 19, 2004 (gmt 0)

10+ Year Member



BonRouge,

Thanks that has answered one of my questions I had. Hadn't posted it yet cause I was sure I would find the answer in here somewhere.

FloppyCopy

2:51 pm on Nov 20, 2004 (gmt 0)

10+ Year Member



Rather than use a one-column, one-row table, you could use a <div>.


<div style="margin: auto; width: x;">

A <div> like the one above should align to the center, but dont' forget to close the tag at the end of your page. (</div>)

In Internet Explorer it will not center unless its parent tag aligns content to the center, so in this case, you'd have to have the 'text-align: center;' item in your body tag's style attribute (assuming you're using CSS).