CSS Horizontally and Vertically Center Element


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



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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.