Posted By

dubogii on 04/01/11


Tagged

css height flexible vertical centering


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

dubogii
dansantucci


Flexible height vertical centering with CSS, beyond IE7


 / Published in: CSS
 

URL: http://www.456bereastreet.com/archive/201103/flexible_height_vertical_centering_with_css_beyond_ie7/

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Flexible height vertical centering with CSS, beyond IE7</title>
  6.  
  7. <style>
  8. html,
  9. body {
  10. width:100%;
  11. height:100%;
  12. }
  13. html {display:table;}
  14. body {
  15. display:table-cell;
  16. vertical-align:middle;
  17. }
  18. #body {
  19. max-width:50em;
  20. margin:0 auto;
  21. border: 1px solid #000;
  22. }
  23. </style>
  24.  
  25. </head>
  26.  
  27. <body>
  28. <div id="body">
  29. Content goes here
  30. </div>
  31. </body>
  32.  
  33. </html>

Report this snippet  

You need to login to post a comment.