티스토리 뷰

WS & SCript

Vertical-align:Middle

Ming's 2008. 7. 15. 14:29


* http://www.badboy.ro/articles/2005-02-20/vertical_align_with_css/

* http://www.jakpsatweb.cz/css/css-vertical-center-solution.html
* http://www.laboratoriocaffeina.it/design/2007/05/11/vertical-centering-in-css-with-unknown-height-ie7-compatible.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html>
<head>
<title>Vertical centering in valid CSS</title>

<style type="text/css">
#outer {height: 400px; overflow: hidden; position: relative;}
#outer[id] {display: table; position: static;}
*:first-child+html #outer[id] {position:relative;} /* for explorer 7 only */

#middle {position: absolute; top: 50%;} /* for explorer only*/
#middle[id] {display: table-cell; vertical-align: middle; position: static;}
 *:first-child+html #middle[id] {position: absolute; display:block; vertical-align:inherit; top: 50%; } /* for explorer 7 only */

#inner {position: relative; top: -50%} /* for explorer only */

/* just format */
div.greenBorder {border: 1px solid green; background-color: ivory;}

 </style>

</head>

<body>
<h1>Vertical Centering in valid CSS - Example</h1>
<div id="outer" class="greenBorder">
 <div id="middle">
  <div id="inner" class="greenBorder">
   any text<br>
   <b>any height</b><br>
   any content, for example generated from DB<br>
   everything is vertically centered<br>
  </div>
 </div>
</div>


</body>
</html>

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/08   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함