Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Centering a DIV within a DIV?
- Robert Latest
October 27, 2005, 6:31 pm
rate this thread
me again. This time I'd like to align a DIV both horizontally and
vertically centered within a larger DIV.
The only alignment-relevant CSS property I could think of was
text-align, and that didn't work.
Of course I could put the DIV into a one-cell table and use the td's
align and vertical-align attributes, but let's assume I don't want to
use tables for that type of stuff.
Re: Centering a DIV within a DIV?
Robert Latest wrote:
For horizontal centering, the inner DIV should have the following
where nn is the desired width as a percentage of the width of the
outer DIV. I do this all the time.
For vertical centering, try doing the same with margin-top,
margin-bottom, and height. I have never done this, so I'm not sure
of the results.
David E. Ross
I use Mozilla as my Web browser because I want a browser that
complies with Web standards. See <URL:http://www.mozilla.org/>.