[thelist] Centering divs in CSS
Tobyn Baugher
toby at rsux.com
Wed Nov 6 10:33:01 CST 2002
On Wed, Nov 06, 2002 at 10:47:41AM -0500, Chris Evans wrote:
> I would like to center a div using CSS. Using {margin-right: auto;
> margin-left: auto;} works in Mozilla, but not IE6.
I use a technique I saw on a site whose name and URL now escapes me
(sorry!). I set "left" to 50% and then set margin-left to
(-1 * (width / 2)). This works in both IE and Mozilla and doesn't
require me to mess with the text alignment at all (which is a bug
anyway, one that I hope will go away soon).
Anyway, simplistic example here: http://rsux.com/
Hope that helps.
Toby
(If any of you are aware of problems with this, please let me know. All
I know is that it validates and works in every browser I've expected it
to. That said, I know I don't spend nearly as much time with HTML as
some of the gurus here and there are parts of the spec I've been
fortunate enough to not commit to memory yet :P.)
--
Tobyn Baugher <toby at rsux.com>
http://www.rsux.com
aim: dieplzkthxbye icq: 14281524 efnet: toby
More information about the thelist
mailing list