Page is a not externally linkable
- Code, Content, and Presentation
-- CSS
---- Vertical centering of DIV


Setek - 3:42 am on Sep 13, 2006 (gmt 0)


If it's fixed-width, fixed-height, this can be done quite easily.

You want it positioned over the top of everything else, so:

  1. fix the width and the height of the div;
  2. absolutely position;
  3. set left and top to 50%;
  4. set negative margin which is half the amount (e.g. if width = 600px, height = 300px, set margin-left = -300px, margin-top = -150px); and
  5. set your z-index higher than your other elements, to position it above everything else.

That's it :)


Thread source:: http://www.webmasterworld.com/css/3080995.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com