|
Posted by Jukka K. Korpela on 08/14/07 20:00
Scripsit DrewC:
> I am trying to position a block in my CSS and I want it to when I
> resize the browser window the margin on both sides remain the same.
> But I can only get the left side to behave this way
Set margin-left: auto and margin-right: auto. Make sure you have a
conforming doctype that puts browsers into "standards" mode, and a) accept
the fact that a fraction of old browsers don't center the block or b) use
HTML tools for centering.
Of course, you need to set a width for the block for this to work. If you
just want, say, 3em margins on both sides and the block to occupy the rest
of the available width, simply set margin-left: 3em and margin-right: 3em
(or just margin: 0 3em if it its OK to explicitly set vertical margins to
zero).
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/
Navigation:
[Reply to this message]
|