1. Flexbox & Grid
  2. justify-self

Flexbox & Grid

justify-self

控制单个网格项目在其内联轴上的对齐方式的功能类。

ClassStyles
justify-self-auto
justify-self: auto;
justify-self-start
justify-self: start;
justify-self-end
justify-self: end;
justify-self-center
justify-self: center;
justify-self-stretch
justify-self: stretch;

示例

Auto(自动)

使用 justify-self-auto 根据网格的 justify-items 属性值来对齐项目:

01
02
03
04
05
06
<div class="grid justify-items-stretch ...">  <!-- ... -->  <div class="justify-self-auto ...">02</div>  <!-- ... --></div>

Start(起始)

使用 justify-self-start 将网格项目对齐到其内联轴的起始位置:

01
02
03
04
05
06
<div class="grid justify-items-stretch ...">  <!-- ... -->  <div class="justify-self-start ...">02</div>  <!-- ... --></div>

Center(居中)

使用 justify-self-center 将网格项目在其内联轴上居中对齐:

01
02
03
04
05
06
<div class="grid justify-items-stretch ...">  <!-- ... -->  <div class="justify-self-center ...">02</div>  <!-- ... --></div>

End(末端)

使用 justify-self-end 将网格项目对齐到其内联轴的末端:

01
02
03
04
05
06
<div class="grid justify-items-stretch ...">  <!-- ... -->  <div class="justify-self-end ...">02</div>  <!-- ... --></div>

Stretch(拉伸)

使用 justify-self-stretch 使网格项目在其内联轴方向上拉伸以填充网格区域:

01
02
03
04
05
06
<div class="grid justify-items-start ...">  <!-- ... -->  <div class="justify-self-stretch ...">02</div>  <!-- ... --></div>

响应式设计

Prefix a justify-self utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:

<div class="justify-self-start md:justify-self-end ...">  <!-- ... --></div>

Learn more about using variants in the variants documentation.

版权所有 © 2025 Tailwind Labs Inc.·商标政策