Posted By

mariusscheel on 03/02/10


Tagged

div center horizontal vertical


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

mvrilo
kubaitis
Bonik
shuchii


Complete Centered DIV (horizontal AND vertical alignment)


 / Published in: CSS
 

URL: http://www.smashingmagazine.com/2009/10/05/mastering-css-coding-getting-started/#CSS-Basics3

  1. .vertical {
  2. width: 600px; /*--Specify Width--*/
  3. height: 300px; /*--Specify Height--*/
  4. position: absolute; /*--Set positioning to absolute--*/
  5. top: 50%; /*--Set top coordinate to 50%--*/
  6. left: 50%; /*--Set left coordinate to 50%--*/
  7. margin: -150px 0 0 -300px; /*--Set negative top/left margin--*/
  8. }

Report this snippet  

You need to login to post a comment.