Re: Centering layers

by "Tim Rivera" <lists(at)timrivera.com>

 Date:  Tue, 16 Sep 2003 17:20:03 -0400
 To:  <hwg-techniques(at)hwg.org>,
"Adrian Harris" <adrian(at)gn.apc.org>
 References:  apc
  todo: View Thread, Original
> is it possible to center layers? I planned to use centered
> or fluid tables, but need to use layers to get the
> behaviour effect I want. One of my students got centering
> after a fashion by setting position with %, but it wasn't
> quite there!

Would you like to horizontally center a box in the normal
flow, or an absolute/relative positioned box?

There is not just one way to center a box in normal flow for
all browsers. For just IE you could wrap a TABLE with a DIV
and give the DIV the CSS "text-align: center", but for Opera
and Mozilla you'd have to give the TABLE automatic left and
right margins:

<div style="text-align: center">
<table style="width: 200px; background: silver; text-align:
left; margin: auto"><tr><td>Some table</td></tr></table>
</div>


To center a positioned box, declare a left position of 50%,
and give a negative left margin for half of the box's width:

<div style="position: absolute; left: 50%;
margin-left: -100px; width: 200px; background: silver">Some
div</div>


Hope this helps,

Tim
____________________________________________________________
http://webdesign.meetup.com/     See you at the next meetup!
http://css.meetup.com/

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA