Thursday 15 February 2007

Centre Block CSS2

To centre a block item, set the margin-left and margin-right CSS properties to 'auto'; this sets the computed values of both margins equal. IE won't listen so set the text-align property of the containing element to center as well.

<div style="width: 500px; text-align: center;">
<div style="margin-left: auto; margin-right: auto; width: 100px;">My stuff</div>

No comments:

Post a Comment

Spam comments will be deleted

Note: only a member of this blog may post a comment.