CSS Horizontally and Vertically Center Element


 / Published in: CSS
 

URL: http://www.dezinerfolio.com/2007/05/02/the-simplest-way-to-horizontally-and-vertically-center-a-div/

  1. /* This will horizontally and vertically center an element, but
  2.   requires that the height and width of it are known */
  3. .centered
  4. {
  5. width:16px;
  6. height:16px;
  7. position:absolute;
  8. top:50%;
  9. left:50%;
  10. margin-left:-8px;
  11. margin-top:-8px;
  12. }

Report this snippet  

You need to login to post a comment.