參考網址:http://www.4byte.cn/question/138712/bootstrap-how-to-center-vertical.html
部分參考自上面網頁中的方法.用過bootstrap的同學知道,bootsrap2中可以使用柵格布局讓div水平居中,那么如何讓水平居中的div又垂直居中呢?
<div class="container">
<div class="row">
<div class="span4 offset4" style="padding:5 20 5 20;">
Some text text text text text .....
</div>
</div>
</div>
直接在css里面設置就可以實現居中,css代碼:
/*web background*/ .container{ display:table; height:100%; } .row{ display: table-cell; vertical-align: middle; }
這樣就實現了div的水平加垂直劇中了,完畢!