内联轴对齐

使用 justify-items 工具类控制栅格项目沿内联轴(在大多数书写模式中为水平方向)的对齐方式。

ClassStyles
.justify-items-startjustify-items: start;
.justify-items-endjustify-items: end;
.justify-items-centerjustify-items: center;
.justify-items-stretchjustify-items: stretch;

概述

在 CSS Grid 容器上使用 justify-items 工具类,以更改栅格项目沿内联(行)轴的对齐方式。此属性控制栅格项目在其栅格区域内的水平定位。

基本用法

使用 justify-items 工具类控制栅格项目的水平对齐。可从 start、end、center 或 stretch(浏览器默认)中选择。

Justify
Items
Start
Justify
Items
End
Justify
Items
Center
Justify
Items
Stretch
HTML
<div class="d-grid justify-items-start">...</div>
<div class="d-grid justify-items-end">...</div>
<div class="d-grid justify-items-center">...</div>
<div class="d-grid justify-items-stretch">...</div>

响应式

justify-items 也有响应式变体。

  • .justify-items-start
  • .justify-items-end
  • .justify-items-center
  • .justify-items-stretch
  • .sm:justify-items-start
  • .sm:justify-items-end
  • .sm:justify-items-center
  • .sm:justify-items-stretch
  • .md:justify-items-start
  • .md:justify-items-end
  • .md:justify-items-center
  • .md:justify-items-stretch
  • .lg:justify-items-start
  • .lg:justify-items-end
  • .lg:justify-items-center
  • .lg:justify-items-stretch
  • .xl:justify-items-start
  • .xl:justify-items-end
  • .xl:justify-items-center
  • .xl:justify-items-stretch
  • .2xl:justify-items-start
  • .2xl:justify-items-end
  • .2xl:justify-items-center
  • .2xl:justify-items-stretch

CSS

Sass 工具类 API

内联轴对齐工具类在我们的工具类 API 中于 scss/_utilities.scss 内声明。了解如何使用工具类 API。

"justify-items": (
  responsive: true,
  property: justify-items,
  values: (
    start: start,
    end: end,
    center: center,
    stretch: stretch,
  )
),