與 Bootstrap 3 垂直對齊 - vertical-align with Bootstrap 3

問題:

I'm using Twitter Bootstrap 3, and I have problems when I want to align vertically two div , for example — JSFiddle link :我正在使用 Twitter Bootstrap 3,當我想垂直對齊兩個div時遇到問題,例如 - JSFiddle 鏈接

<!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> <!-- Optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css"> <!-- Latest compiled and minified JavaScript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <div class="row"> <div class="col-xs-5"> <div style="height:5em;border:1px solid #000">Big</div> </div> <div class="col-xs-5"> <div style="height:3em;border:1px solid #F00">Small</div> </div> </div>

The grid system in Bootstrap uses float: left , not display:inline-block , so the property vertical-align doesn't work. Bootstrap 中的網格系統使用float: left ,而不是display:inline-block ,因此屬性vertical-align不起作用。 I tried using margin-top to fix it, but I think this is not a good solution for the responsive design.我嘗試使用margin-top來修復它,但我認爲這對於響應式設計來說不是一個好的解決方案。


解決方案:

參考一: https://stackoom.com/question/1ODQR
參考二: vertical-align with Bootstrap 3
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章