Frontendplace Blog

Sharing Frontend developing ideas

Centering html content vertical and horizontal

Posted by info on November 1st, 2008

How to center your page in the middle and vertical align on center?

  • you need a width and a height of your page. 

    width:768px;height: 630px;

  • position is absolute
  • position top and left to %50:

    top: 50%;
    left: 50%;

  • compensate for the offset with the 1/2 of the width and height

    margin-left: -384px;
    margin-top: -315px;
     

an example see this page