Flexbox & Grid

justify-items

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

ClassStyles
justify-items-start
justify-items: start;
justify-items-end
justify-items: end;
justify-items-end-safe
justify-items: safe end;
justify-items-center
justify-items: center;
justify-items-center-safe
justify-items: safe center;
justify-items-stretch
justify-items: stretch;
justify-items-normal
justify-items: normal;

範例(Examples)

起點(Start)

使用 justify-items-start 通用類別將 grid 項目對齊其行內軸的起點:

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

終點(End)

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

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

justify-items-end

01
02
03

justify-items-end-safe

01
02
03
justify-items-end
<div class="grid grid-flow-col justify-items-end ...">  <div>01</div>  <div>02</div>  <div>03</div></div>
justify-items-end-safe
<div class="grid grid-flow-col justify-items-end-safe ...">  <div>01</div>  <div>02</div>  <div>03</div></div>

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

置中(Center)

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

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

justify-items-center

01
02
03

justify-items-center-safe

01
02
03
justify-items-center
<div class="grid grid-flow-col justify-items-center ...">  <div>01</div>  <div>02</div>  <div>03</div></div>
justify-items-center-safe
<div class="grid grid-flow-col justify-items-center-safe ...">  <div>01</div>  <div>02</div>  <div>03</div></div>

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

伸展(Stretch)

使用 justify-items-stretch 通用類別沿項目的行內軸伸展:

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

響應式設計(Responsive design)

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

<div class="grid justify-items-start md:justify-items-center ...">  <!-- ... --></div>

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

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