Flexbox & Grid

justify-self

用於控制單一 grid 項目如何沿其行內軸對齊的通用類別。

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

範例(Examples)

自動(Auto)

使用 justify-self-auto 通用類別根據 grid 的 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 通用類別將 grid 項目對齊其行內軸的起點:

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

置中(Center)

使用 justify-self-centerjustify-self-center-safe 通用類別將 grid 項目沿其行內軸置中對齊:

調整容器大小以查看對齊行為

justify-self-center

01
02
03

justify-self-center-safe

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

當可用空間不足時,justify-self-center-safe 通用類別會將項目對齊到容器起點而非中心。

終點(End)

使用 justify-self-endjustify-self-end-safe 通用類別將 grid 項目對齊其行內軸的終點:

調整容器大小以查看對齊行為

justify-self-end

01
02
03

justify-self-end-safe

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

當可用空間不足時,justify-self-end-safe 通用類別會將項目對齊到容器起點而非終點。

伸展(Stretch)

使用 justify-self-stretch 通用類別將 grid 項目伸展以填滿其行內軸上的 grid 區域:

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

響應式設計(Responsive design)

justify-self 通用類別前面加上像 md: 這樣的中斷點變體,讓該通用類別只在中型螢幕尺寸及以上時套用:

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

變體文件中了解更多關於使用變體的資訊。

Copyright © 2026 Tailwind Labs Inc.·商標政策(Brand)