Horizontal and Vertical CSS Centering


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



Copy this code and paste it in your HTML
  1. .centered { width: 300px;
  2. height: 304px;
  3. left: 50%;
  4. top: 50%;
  5. margin: -150px 0 0 -150px; /*-- halfs of the centered DIV height in width --*/
  6. position: fixed; }
  7.  
  8. * html .centered { position:absolute; } /*-- IE6 fix --*/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.