垂直对齐(Vertical align)
轻松更改内联、内联块、内联表格和表格单元格元素的垂直对齐方式。
使用vertical-alignment utilities 更改元素对齐方式。 请注意,vertical-align 只影响 inline、inline-block、inline-table 和表格单元格元素。
根据需要选择 .align-baseline、.align-top、.align-middle、.align-bottom、.align-text-bottom 和 .align-text-top。
要使非内联内容(如 <div> 等)垂直居中,请使用我们的 flex box 实用程序。
使用内联元素:
baseline
top
middle
bottom
text-top
text-bottom
<span class="align-baseline">baseline</span>
<span class="align-top">top</span>
<span class="align-middle">middle</span>
<span class="align-bottom">bottom</span>
<span class="align-text-top">text-top</span>
<span class="align-text-bottom">text-bottom</span>使用表格单元格:
| baseline | top | middle | bottom | text-top | text-bottom |
<table style="height: 100px;">
<tbody>
<tr>
<td class="align-baseline">baseline</td>
<td class="align-top">top</td>
<td class="align-middle">middle</td>
<td class="align-bottom">bottom</td>
<td class="align-text-top">text-top</td>
<td class="align-text-bottom">text-bottom</td>
</tr>
</tbody>
</table>CSS
Sass utilities API
垂直对齐实用程序在我们的实用程序 API 中声明,位于 scss/_utilities.scss 中。了解如何使用实用程序 API
"align": (
property: vertical-align,
class: align,
values: baseline top middle bottom text-bottom text-top
),