跳到主要内容
输入关键词开始搜索,↑ ↓ 选择,Enter 打开
没有找到匹配的文档

垂直对齐

轻松更改内联、内联块、内联表格和表格单元格元素的垂直对齐方式。

本页目录
类名样式
.align-baselinevertical-align: baseline;
.align-topvertical-align: top;
.align-middlevertical-align: middle;
.align-bottomvertical-align: bottom;
.align-text-bottomvertical-align: text-bottom;
.align-text-topvertical-align: text-top;

使用 vertical-alignment 工具更改元素的对齐方式。请注意,vertical-align 仅影响 inline、inline-block、inline-table 和表格单元格元素。

根据需要从.align-baseline、.align-top、.align-middle、.align-bottom、.align-text-bottom和.align-text-top中选择。

要垂直居中非内联内容(如 <div>s 等),请使用我们的 弹性盒子工具。

带有内联元素:

基线 顶部 中间 底部 文本顶部 文字底部
HTML
<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>

带有表格单元格:

基线顶部中间底部文本顶部文字底部
HTML
<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 工具 API

垂直对齐工具在我们的工具 API scss/_utilities.scss 中声明。了解如何使用工具 API。

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