[bootstrap]bootstrap2如何引導div垂直居中


參考網址: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的水平加垂直劇中了,完畢!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM