Advertisement
falkirks

PERFECTLY CENTER DIV

Apr 19th, 2013
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.87 KB | None | 0 0
  1. <style>
  2.  
  3. html, body {
  4.     height: 100%;         /* required */
  5. }
  6. body {
  7.     text-align: center;   /* horizontal centering hack for IE */
  8.     padding: 0;           /* required to "hide" distance div */
  9.     margin: 0;            /* required to "hide" distance div */
  10. }
  11. div#distance {
  12.     margin-bottom: -10em; /* half of content height */
  13.     width: 1px;           /* required to "hide" distance div */
  14.     height: 50%;          /* required */
  15.     float: left;          /* required */
  16.  
  17. }
  18. div#content {
  19.     position: relative;   /* positions content on top of distance */
  20.     text-align: left;     /* horizontal centering hack for IE */
  21.     height: 400px;         /* required - desired height */
  22.     width: 500px;          /* required - desired width */
  23.     margin: 0 auto;       /* required */
  24.     clear: left;          /* required */
  25. }
  26. </style>
  27.  
  28. <body>
  29.    <div id="distance"></div>
  30.    <div id="content">
  31. Content Here
  32. </div>
  33. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement