将最后一个 div 对齐到 flexbox 的底部

Aligning the last div to the bottom of a flexbox

场景:

试用案例:

代码:

<div class='pricing__tier'>
 <div class='uni-card-header'>
 </div>
 <div class='uni-card-body'>
   <div class='uni-row-on'>
   </div>
   <div class='uni-row-off'>
   </div>
   <div class='uni-row-on card-vat-fee'>
    <div class='vat-fee-text'>
     Credit card fees and VAT apply. See below for details.
    </div>
   </div>
 </div>
</div>
<style>
    .pricing__tier {
        padding: 0;
        text-align: center;
        display: flex;
        flex-direction: column;
        width: 0%;
        flex: 1;
    }
    .uni-card-body {
        display: flex;
        flex-direction: column;
    }
</style>

定价层


请建议。
提前致谢

1-设置parent div相对位置无top & left & right & 底部 属性

2- 设置最后一个 div 绝对位置 bottom:0;right:0;left:0;height:36px;

<style>
  .pricing__tier {
    position:relative;
    padding: 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    width: 0%;
    flex: 1;
  }
  .pricing__tier>.vat-fee-text {
    position:absolute;
    bottom:0;
    right:0;
    left:0;
    height:36px;
  }
 </style>

请试试这个:

.uni-card-body {
        display: flex;
        flex-direction: column;
        width: 'for example' 700px;
    }
    .uni-row-on.card-vat-fee{
    align-self: flex-end;
}

希望对您有所帮助!

.uni-card-body {
  display: flex;
  flex-flow: row wrap;
  justify-content: center;
  background: yellow;
  height: 90vh;
}

.uni-row-on.card-vat-fee {
  align-self: flex-end;
  background: green;
}
<div class='pricing__tier'>
  <div class='uni-card-header'>
  </div>
  <div class='uni-card-body'>
    <div class='uni-row-on'>
    </div>
    <div class='uni-row-off'>
    </div>
    <div class='uni-row-on card-vat-fee'>
      <div class='vat-fee-text'>
        Credit card fees and VAT apply. See below for details.
      </div>
    </div>
  </div>
</div>

我已经在代码片段中说明了事情,它会有所帮助。

Note: Content justification, background and height are for demonstration and not necessary.

在最后一个div上使用margin-top:auto

.pricing__tier {
  padding: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  width: 25%;
  flex: 1;
  height: 200px; /* for demo purposes */
  border: 1px solid grey;
}

.uni-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-vat-fee {
  margin-top: auto; /* push to bottom */
  background: green;
}
<div class='pricing__tier'>
  <div class='uni-card-header'>
  </div>
  <div class='uni-card-body'>
    <div class='uni-row-on'>
    </div>
    <div class='uni-row-off'>
    </div>
    <div class='uni-row-on card-vat-fee'>
      <div class='vat-fee-text'>
        Credit card fees and VAT apply. See below for details.
      </div>
    </div>
  </div>
</div>