Vertical alignment

Easily change the vertical alignment of inline, inline-block, inline-table, and table cell elements.

Change the alignment of elements with the vertical-alignment utilities. Please note that vertical-align only affects inline, inline-block, inline-table, and table cell elements.

Choose from .align-baseline, .align-top, .align-middle, .align-bottom, .align-text-bottom, and .align-text-top as needed.

To vertically center non-inline content (like <div>s and more), use our flex box utilities.

With inline elements:

Vertical align - 图1

html

  1. <span class="align-baseline">baseline</span>
  2. <span class="align-top">top</span>
  3. <span class="align-middle">middle</span>
  4. <span class="align-bottom">bottom</span>
  5. <span class="align-text-top">text-top</span>
  6. <span class="align-text-bottom">text-bottom</span>

With table cells:

Vertical align - 图2

html

  1. <table style="height: 100px;">
  2. <tbody>
  3. <tr>
  4. <td class="align-baseline">baseline</td>
  5. <td class="align-top">top</td>
  6. <td class="align-middle">middle</td>
  7. <td class="align-bottom">bottom</td>
  8. <td class="align-text-top">text-top</td>
  9. <td class="align-text-bottom">text-bottom</td>
  10. </tr>
  11. </tbody>
  12. </table>

CSS

Sass utilities API

Vertical align utilities are declared in our utilities API in scss/_utilities.scss. Learn how to use the utilities API.

scss/_utilities.scss

  1. "align": (
  2. property: vertical-align,
  3. class: align,
  4. values: baseline top middle bottom text-bottom text-top
  5. ),