弹性盒子与网格
用于控制项目如何同时进行对齐和排列的实用程序。
Class | Styles |
---|---|
place-items-start | place-items: start; |
place-items-end | place-items: end; |
place-items-center | place-items: center; |
place-items-baseline | place-items: baseline; |
place-items-stretch | place-items: stretch; |
使用 place-items-start
将网格项目放置在其网格区域的起始位置(两个轴):
<div class="grid grid-cols-3 place-items-start gap-4 ..."> <div>01</div> <div>02</div> <div>03</div> <div>04</div> <div>05</div> <div>06</div></div>
使用 place-items-end
将网格项目放置在其网格区域的结束位置(两个轴):
<div class="grid h-56 grid-cols-3 place-items-end gap-4 ..."> <div>01</div> <div>02</div> <div>03</div> <div>04</div> <div>05</div> <div>06</div></div>
使用 place-items-center
将网格项目放置在其网格区域的中央(两个轴):
<div class="grid h-56 grid-cols-3 place-items-center gap-4 ..."> <div>01</div> <div>02</div> <div>03</div> <div>04</div> <div>05</div> <div>06</div></div>
使用 place-items-stretch
按两个轴拉伸网格区域内的项目:
<div class="grid h-56 grid-cols-3 place-items-stretch gap-4 ..."> <div>01</div> <div>02</div> <div>03</div> <div>04</div> <div>05</div> <div>06</div></div>
Prefix a place-items
utility with a breakpoint variant like md:
to only apply the utility at medium screen sizes and above:
<div class="grid place-items-start md:place-items-center ..."> <!-- ... --></div>
Learn more about using variants in the variants documentation.