我想在底部对齐img在jumbotron中,但无法弄清楚。不能底部对齐图像在jumbotron
<div class="jumbotron">
<div class="container">
<div class="row">
<div class="col-lg-8">
<h1>Hello, world!</h1>
<p>This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class="btn btn-primary btn-lg">Learn more »</a></p>
</div>
<div class="col-lg-4 text-center">
<img src="http://via.placeholder.com/200x200">
</div>
</div>
</div>
</div>
我尝试添加以下的CSS
.vertical-bottom {
display: flex;
align-items: bottom;
}
然后将包含IMG
<div class="col-lg-4 text-center vertical-bottom">
这不起作用增加的附加类的DIV,为什么很难在引导中垂直对齐的东西?
问题不在于引导程序。垂直居中的东西一直是半困难的,直到弹性盒被支持。但Bootstrap 4允许您使用与其列/网格系统配合使用的弹性框类。回到问题,你想达到什么结果?图像将水平居中,但低于标题,文本和按钮? –
@ hunter-mitchell我希望图像水平居中,底部与包含标题,文本和按钮的div侧面对齐。所以1行与2列两个底部对齐。我考虑试图找出标题,文本和按钮的div的高度,然后设置图像的顶部边距以获得底部对齐。但是,我不确定如何获得该div的高度? – user13317
Bootstrap 4具有一个非常好的支持flexbox的网格系统。我建议您使用它(不需要移除两列上的浮动块并手动定位每列,以便可以将儿童高度设置为100%)。当我得到一个改变生病的时候抛出一个例子。 –