Help - Search - Members - Calendar
Full Version: Centred
HTMLHelp Forums > Web Authoring > Cascading Style Sheets
James
The bottom paragraph on my first page (http://www.warural.com.au/) is meant to be centred, and you can see that each line is atually centred around a medial axis, but that axis is not in the centre of the page. The paragraph seems to be centred, and then offset to the left.

Can any of you wise men or ladies tell me why this is so?

Many thanks, James
Darin McGrew
It looks like the problem is
CODE
p.w90        {width: 90%;
             text-align: center;
         }

This makes the paragraph 90% of the width of its containing element (a div element, FWIW). Since you haven't specified margins, the left margin is 0, and the right margin is 10%.

Turning on borders and/or background colors makes it easier to see what's going on when you're debugging layouts.
James
QUOTE(Darin McGrew @ Jul 9 2007, 12:07 AM) *

It looks like the problem is
CODE
p.w90        {width: 90%;
             text-align: center;
         }

This makes the paragraph 90% of the width of its containing element (a div element, FWIW). Since you haven't specified margins, the left margin is 0, and the right margin is 10%.

Turning on borders and/or background colors makes it easier to see what's going on when you're debugging layouts.


Thanks Darin
zoogies
You can still have it at 90% width, but centered, by specifying

CODE

{
margin: 0 auto;
}


in your CSS.
Darin McGrew
Keep in mind that you have to put MSIE into "standards mode" before it will understand what to do with margin values of "auto".
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.