Flexbox & Grid
用於控制 grid 項目如何沿其行內軸對齊的通用類別。
| Class | Styles |
|---|---|
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; |
使用 justify-items-start 通用類別將 grid 項目對齊其行內軸的起點:
<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>使用 justify-items-end 或 justify-items-end-safe 通用類別將 grid 項目對齊其行內軸的終點:
調整容器大小以查看對齊行為
justify-items-end
justify-items-end-safe
<div class="grid grid-flow-col justify-items-end ..."> <div>01</div> <div>02</div> <div>03</div></div><div class="grid grid-flow-col justify-items-end-safe ..."> <div>01</div> <div>02</div> <div>03</div></div>當可用空間不足時,justify-items-end-safe 通用類別會將項目對齊到容器起點而非終點。
使用 justify-items-center 或 justify-items-center-safe 通用類別將 grid 項目沿其行內軸置中對齊:
調整容器大小以查看對齊行為
justify-items-center
justify-items-center-safe
<div class="grid grid-flow-col justify-items-center ..."> <div>01</div> <div>02</div> <div>03</div></div><div class="grid grid-flow-col justify-items-center-safe ..."> <div>01</div> <div>02</div> <div>03</div></div>當可用空間不足時,justify-items-center-safe 通用類別會將項目對齊到容器起點而非中心。
使用 justify-items-stretch 通用類別沿項目的行內軸伸展:
<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>在 justify-items 通用類別前面加上像 md: 這樣的中斷點變體,讓該通用類別只在中型螢幕尺寸及以上時套用:
<div class="grid justify-items-start md:justify-items-center ..."> <!-- ... --></div>在變體文件中了解更多關於使用變體的資訊。