Skip to main content Skip to docs navigation
View on GitHub

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. 使用vertical-alignment实用程序更改图元的对齐方式。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.根据需要选择.align-baseline.align-top.align-middle.align-bottom.align-text-bottom.align-text-top

To vertically center non-inline content (like <div>s and more), use our flex box utilities.要垂直居中非内联内容(如<div>等),请使用弹性盒实用程序

With inline elements:对于内联元素:

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>

With table cells:

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>

Sass

Utilities API实用程序API

Vertical align utilities are declared in our utilities API in scss/_utilities.scss. 垂直对齐实用程序在scss/_utilities.scss中的实用程序API中声明。Learn how to use the utilities API.了解如何使用实用程序API。

    "align": (
property: vertical-align,
class: align,
values: baseline top middle bottom text-bottom text-top
),