Welcome to WebmasterWorld Guest from 188.8.131.52
Forum Moderators: not2easy
Set up your container div class something like this.
The effect of this is to push the left edge of the box to the exact middle of the page (left=50%), then pull it back by half the width off the container (-50%); thus exactly centering the box (div.ctr).
Setting the box size in ems works with any browser font size setting, and every browser (I Believe).
Thanks for the message, but I didn't see it till today. Responses need to be via the forum reply, or other readers will never get to see the response.
Hi, you posted to my question about center a div, but I dont understand. ....If you could contact me on AIM at....
Put whatever you want to center in a box (DIV) and set its width and position. Like this:
Then center the left edge of the container on the page -
Next, move the container left by half its own width -
margin-left: -50%; // or in this case, 400px.
The effect is to move the left edge of the container back by half its own width from the page center, thus exactly centering the page, no matter what width the screen is.
Next put your content in the div -
Your nicely centered content entered in here
This is a proven cross browser method of centering page content.
Here is a shorthand way that only works with the newer browsers.
margin-left; 20px auto;