Flexbox & Grid
控制 flex 和 grid 容器中的项目如何沿主轴定位的功能类。
| Class | Styles |
|---|---|
justify-start | justify-content: flex-start; |
justify-end | justify-content: flex-end; |
justify-center | justify-content: center; |
justify-between | justify-content: space-between; |
justify-around | justify-content: space-around; |
justify-evenly | justify-content: space-evenly; |
justify-stretch | justify-content: stretch; |
justify-baseline | justify-content: baseline; |
justify-normal | justify-content: normal; |
使用 justify-start 将项目对齐到容器主轴的起始位置:
<div class="flex justify-start ..."> <div>01</div> <div>02</div> <div>03</div></div>使用 justify-center 将项目沿容器主轴居中对齐:
<div class="flex justify-center ..."> <div>01</div> <div>02</div> <div>03</div></div>使用 justify-end 将项目对齐到容器主轴的末端:
<div class="flex justify-end ..."> <div>01</div> <div>02</div> <div>03</div></div>使用 justify-between 使项目沿容器主轴均匀分布,项目之间保持相等的间距:
<div class="flex justify-between ..."> <div>01</div> <div>02</div> <div>03</div></div>使用 justify-around 使项目沿容器主轴均匀分布,每个项目两侧保持相等的间距:
<div class="flex justify-around ..."> <div>01</div> <div>02</div> <div>03</div></div>使用 justify-evenly 使项目沿容器主轴均匀分布,每个项目周围保持相等的间距,同时考虑到使用 justify-around 时项目之间通常会出现的双倍间距:
<div class="flex justify-evenly ..."> <div>01</div> <div>02</div> <div>03</div></div>使用 justify-stretch 允许内容项目沿容器主轴填充可用空间:
<div class="grid grid-flow-col ..."> <div>01</div> <div>02</div> <div>03</div></div>使用 justify-normal 使内容项目按默认位置排列,就像没有设置 justify-content 值一样:
<div class="flex justify-normal ..."> <div>01</div> <div>02</div> <div>03</div></div>Prefix a justify-content utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:
<div class="flex justify-start md:justify-between ..."> <!-- ... --></div>Learn more about using variants in the variants documentation.