| Class | Styles |
|---|---|
| .justify-content-start | justify-content: flex-start; |
| .justify-content-end | justify-content: flex-end; |
| .justify-content-center | justify-content: center; |
| .justify-content-between | justify-content: space-between; |
| .justify-content-around | justify-content: space-around; |
| .justify-content-evenly | justify-content: space-evenly; |
概述
在 flexbox 容器上使用 justify-content 工具类,以更改 flex 项目在主轴上的对齐方式(开始时为 x 轴,如果 flex-direction: column 则为 y 轴)。可从 start(浏览器默认)、end、center、between、around 或 evenly 中选择。
基本用法
Justify
Content
Start
Justify
Content
End
Justify
Content
Center
Justify
Content
Between
Justify
Content
Around
Justify
Content
Evenly
<div class="d-flex justify-content-start">...</div>
<div class="d-flex justify-content-end">...</div>
<div class="d-flex justify-content-center">...</div>
<div class="d-flex justify-content-between">...</div>
<div class="d-flex justify-content-around">...</div>
<div class="d-flex justify-content-evenly">...</div>响应式
justify-content 也有响应式变体。
.justify-content-start.justify-content-end.justify-content-center.justify-content-between.justify-content-around.justify-content-evenly.sm:justify-content-start.sm:justify-content-end.sm:justify-content-center.sm:justify-content-between.sm:justify-content-around.sm:justify-content-evenly.md:justify-content-start.md:justify-content-end.md:justify-content-center.md:justify-content-between.md:justify-content-around.md:justify-content-evenly.lg:justify-content-start.lg:justify-content-end.lg:justify-content-center.lg:justify-content-between.lg:justify-content-around.lg:justify-content-evenly.xl:justify-content-start.xl:justify-content-end.xl:justify-content-center.xl:justify-content-between.xl:justify-content-around.xl:justify-content-evenly.2xl:justify-content-start.2xl:justify-content-end.2xl:justify-content-center.2xl:justify-content-between.2xl:justify-content-around.2xl:justify-content-evenly
CSS
Sass 工具类 API
主轴对齐工具类在我们的工具类 API 中于 scss/_utilities.scss 内声明。了解如何使用工具类 API。
"justify-content": (
responsive: true,
property: justify-content,
values: (
start: flex-start,
end: flex-end,
center: center,
between: space-between,
around: space-around,
evenly: space-evenly,
)
),