Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Centered column?

Centered column?
Thread Tools
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Feb 1, 2005, 11:44 AM
 
Forgive my stupid question, but can any one tell this novice how do I get a container to center horizontally on the page? CSS seems to only have vertical alignment settings.

Thanks!

Any BEST of the BEST book recommendations for CSS would be welcome as well.
     
Dedicated MacNNer
Join Date: Nov 2004
Location: Stockholm, Sweden
Status: Offline
Reply With Quote
Feb 1, 2005, 02:46 PM
 
Originally posted by headbirth:
Forgive my stupid question, but can any one tell this novice how do I get a container to center horizontally on the page? CSS seems to only have vertical alignment settings.

Thanks!

Any BEST of the BEST book recommendations for CSS would be welcome as well.
read this, and then buy his book.
     
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Feb 1, 2005, 04:31 PM
 
There are basically two ways to do this, depending on whether or not you've set a width for the column. They both involve setting the column's left and right margins to the same value; it's just a matter of what value you give it.

If you've set a width for the column (in pixels, points, percentage, or anything else), then set margin-left and margin-right to "auto" (no quotes). This will put enough space on each side to center the column.

If you haven't set a width for the column (so that it will be as wide as it can possibly get), then set margin-left and margin-right to however much space you want on both sides. All that matters is that you set them to the same value; as long as you do that then it can be anything you want (px, em, %, or whatever). You can also play with this to make your column be slightly (or even greatly) off-center, by setting margin-left and margin-right to different values.
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Feb 2, 2005, 08:14 AM
 
Great! Thanks for the links and recommendation!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:07 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2