Center div in another div


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



Copy this code and paste it in your HTML
  1. #wrapper {
  2. position:relative;
  3. }
  4. #centeredBox {
  5. position:absolute;
  6. top: 50%;
  7. left: 50%;
  8. width:200px;
  9. height:300px;
  10. margin-left: -100px; /*1/2 width*/
  11. margin-top: -150px; /*1/2 of height*/
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.