Posted By

Tate on 01/18/09


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

ozayo
fabianwizenfeld
johnnytoobad


Vertical Align in a div


 / Published in: CSS
 

  1. .wrap {
  2. display: table;
  3. height: 400px;
  4. #width: 175px; /* arbitrary width for IE only */
  5. #position: relative; /* for IE only */
  6. overflow: hidden;
  7. }
  8. .inner {
  9. #position: absolute; /* for IE only */
  10. #top: 50%; /* for IE only */
  11. display: table-cell;
  12. vertical-align: middle;
  13. }
  14. .content {
  15. #position: relative; /* for IE only */
  16. #top: -50%; /* for IE only */
  17. }
  18. .wrap, .content {border: 1px solid green;} /* just borders to see it */
  19. p {padding:5px;}
  20.  
  21.  
  22. <div class="wrap">
  23. <div class="inner">
  24. <div class="content">
  25. <p>Any content vertically centered.</p>
  26. </div>
  27. </div>
  28. </div>

Report this snippet  

You need to login to post a comment.