Complete Centered DIV (horizontal AND vertical alignment)


/ Published in: CSS
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.