与Bootstrap 3垂直对齐

筅森魡賤 提交于 2020-04-19 06:29:35

问题:

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/与Bootstrap-垂直对齐
参考二: https://oldbug.net/q/1ODQR/vertical-align-with-Bootstrap-3
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!