Выравнивание по главной оси (justify-content)
Используйте утилиты justify-content, чтобы изменять выравнивание flex-элементов по главной оси.
| Класс | Стили |
|---|---|
| .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; |
Обзор
Используйте утилиты justify-content на flexbox-контейнерах для изменения выравнивания flex-элементов по главной оси (x-ось для начала, y-ось если flex-direction: column). Выбирайте из start (по умолчанию в браузере), end, center, between, around или 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
API утилит Sass
Утилиты justify-content объявлены в нашем 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,
)
),