垂直居中對齊的方法
信息來源:
優度網絡 發布日期:2009/4/6 瀏覽數量:
955次
文章導讀:
body {padding: 0; margin: 0;}body,html{height: 100%;}
#outer {height: 100%; overflow: hidden; position: relative;width: 100%; background:ivory;}
#outer[id] {display: table; position: static;}
#middle {position: absolute; top: 50%;} /* for explorer only*/
#middle[id] {display: table-cell; vertical-align: middle; position: static;}
#inner {position: relative; top: -50%;width: 400px;margin: 0 auto;} /* for explorer only */
div.greenBorder {border: 1px solid green; background-color: ivory;}
<div id="outer">
<div id="middle">
<div id="inner" class="greenBorder">
</div>
</div>
</div>