首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在底部具有相同高度的flexbox中的所有div

在底部具有相同高度的flexbox中的所有div
EN

Stack Overflow用户
提问于 2019-03-04 22:38:27
回答 1查看 98关注 0票数 1

我用下面的html用bootstrap 4构建了一个网格。

代码语言:javascript
复制
<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>

我希望日期总是在第二行的底部。也许图片更好地解释了这个问题。前三个日期与弹性框底部的第四个日期不在同一行中:

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-04 22:56:36

无法在不同的flexbox父组件的子组件中平等地对齐内容。但是,您可以使用d-flex,然后使用mt-auto (margin-top:auto)将日期推到列的底部,从而使列也成为flexbox容器。

代码语言:javascript
复制
        <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>

演示:https://www.codeply.com/go/gLYW7liCfc

另请参阅:bootstrap 4 cards - vertical alignment body with variable header line rows

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54985467

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档