twitter-bootstrap - flexbox中所有高度相同的div在底部
问题描述
我有以下 html 来使用 bootstrap 4 构建网格。
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="row">
<div class="col-sm-12 col-md-3">
<div class="row">
<div class="col-lg-12">
here are different heights possible
</div>
</div>
<div class="row align-items-end">
<div class="col-lg-12 date">
should always be at bottom (like the fourth date)
</div>
</div>
</div>
<div class="col-sm-12 col-md-3">
<div class="row">
<div class="col-lg-12">
here are different heights possible
</div>
</div>
<div class="row align-items-end">
<div class="col-lg-12 date">
should always be at bottom (like the fourth date)
</div>
</div>
</div>
<div class="col-sm-12 col-md-3">
<div class="row">
<div class="col-lg-12">
here are different heights possible
here are different heights possible
here are different heights possible
</div>
</div>
<div class="row align-items-end">
<div class="col-lg-12 date">
should always be at bottom (like the fourth date)
</div>
</div>
</div>
</div>
我希望日期始终位于第二行的底部。也许这张图片更好地解释了这个问题。前三个日期与弹性框底部的第四个日期不在同一条线上:
解决方案
没有办法平等地对齐不同flexbox 父级的子级中的内容。d-flex
但是,您可以使用然后mt-auto
( )使列也成为 flexbox 容器margin-top:auto
,将日期推到列的底部。
<div class="col-sm-12 col-md-3 d-flex flex-column">
<div class="row">
<div class="col-lg-12">
here are different heights possible
</div>
</div>
<div class="row mt-auto">
<div class="col-lg-12 date">
date
</div>
</div>
</div>
推荐阅读
- android - Android Firebase,无法获取数据
- ruby-on-rails - 将现有项目添加到待办事项列表
- java - 如何使用相同的日期数据格式化具有特定格式的日期?
- ios - 如何仅使用情节提要更改方向更改时的视图位置
- ios - 为什么向下转换时我不必使用 ItemsTableViewController 的初始化程序?是否已初始化?
- python - 使用 pandas 数据帧列表
- java - Gluon VM StackOverflowError
- at-command - 问:不同应用程序的不同行为(总是重复上一个命令(默认版本 - ATI))
- c# - UdpClient.ReceiveAsync() 方法是否确保一次性接收数据报?
- r - ggplot:多面条形图中的 weighted.mean 和 stat_summary