如何使用 bootstrap 垂直对齐文本 4

how to align text vertically with bootstrap 4

在 class h-50 上,我如何使用 bootstrap 4

将文本与 div 的底部对齐

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<div style='height:300px;border:1px solid #333;'>
                <div class="bg-primary d-inline-block h-25">Height 25%</div>
                <div class="bg-primary d-inline-block text-bottom h-50"><span class='text-bottom'>Height 50%</span></div>
                <div class="bg-primary d-inline-block h-75">Height 75%</div>
                <div class="bg-primary d-inline-block h-100">Height 100%</div>
                <div class="bg-primary d-inline-block h-auto">Height Auto</div>
            </div>

Bootstrap 4 中的一种可能性是在 h-50 div 上使用 d-inline-flex flex-column,然后在 div 上使用 d-flex align-items-end h-100将要对齐的跨度包装在底部:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div style='height:300px;border:1px solid #333;'>
  <div class="bg-primary d-inline-block h-25">Height 25%</div>
  <div class="bg-primary d-inline-flex flex-column h-50">
      <div class="bg-secondary d-flex align-items-end h-100">
          <span>Height 50%</span>
      </div>
  </div>
  <div class="bg-primary d-inline-block h-75">Height 75%</div>
  <div class="bg-primary d-inline-block h-100">Height 100%</div>
  <div class="bg-primary d-inline-block h-auto">Height Auto</div>
</div>