1. Flexbox и Grid
  2. justify-content

Flexbox и Grid

justify-content

Утилиты для управления тем, как flex и grid элементы позиционируются вдоль главной оси контейнера.

ClassStyles
justify-start
justify-content: flex-start;
justify-end
justify-content: flex-end;
justify-end-safe
justify-content: safe flex-end;
justify-center
justify-content: center;
justify-center-safe
justify-content: safe 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;

Примеры

Start

Используйте утилиту justify-start для выравнивания элементов по началу главной оси контейнера:

01
02
03
<div class="flex justify-start ...">  <div>01</div>  <div>02</div>  <div>03</div></div>

Center

Используйте утилиты justify-center или justify-center-safe для выравнивания элементов по центру главной оси контейнера:

Измените размер контейнера, чтобы увидеть поведение выравнивания

justify-center

01
02
03
04

justify-center-safe

01
02
03
04
justify-center
<div class="flex justify-center ...">  <div>01</div>  <div>02</div>  <div>03</div>  <div>04</div></div>
justify-center-safe
<div class="flex justify-center-safe ...">  <div>01</div>  <div>02</div>  <div>03</div>  <div>04</div></div>

Когда недостаточно доступного места, утилита justify-center-safe будет выравнивать элементы по началу контейнера вместо центра.

End

Используйте утилиты justify-end или justify-end-safe для выравнивания элементов по концу главной оси контейнера:

Измените размер контейнера, чтобы увидеть поведение выравнивания

justify-end

01
02
03
04

justify-end-safe

01
02
03
04
justify-end
<div class="flex justify-end ...">  <div>01</div>  <div>02</div>  <div>03</div>  <div>03</div></div>
justify-end-safe
<div class="flex justify-end-safe ...">  <div>01</div>  <div>02</div>  <div>03</div>  <div>03</div></div>

Когда недостаточно доступного места, утилита justify-end-safe будет выравнивать элементы по началу контейнера вместо конца.

Space between

Используйте утилиту justify-between для выравнивания элементов вдоль главной оси контейнера так, чтобы между каждым элементом было равное количество места:

01
02
03
<div class="flex justify-between ...">  <div>01</div>  <div>02</div>  <div>03</div></div>

Space around

Use the justify-around utility to justify items along the container's main axis such that there is an equal amount of space on each side of each item:

01
02
03
<div class="flex justify-around ...">  <div>01</div>  <div>02</div>  <div>03</div></div>

Space evenly

Use the justify-evenly utility to justify items along the container's main axis such that there is an equal amount of space around each item, but also accounting for the doubling of space you would normally see between each item when using justify-around:

01
02
03
<div class="flex justify-evenly ...">  <div>01</div>  <div>02</div>  <div>03</div></div>

Stretch

Use the justify-stretch utility to allow content items to fill the available space along the container's main axis:

01
02
03
<div class="flex justify-stretch ...">  <div>01</div>  <div>02</div>  <div>03</div></div>

Normal

Use the justify-normal utility to pack content items in their default position as if no justify-content value was set:

01
02
03
<div class="flex justify-normal ...">  <div>01</div>  <div>02</div>  <div>03</div></div>

Адаптивный дизайн

Префикс a justify-content утилита с вариантом контрольной точки, например md:, чтобы применить утилиту только при размерах экрана medium и выше:

<div class="flex justify-start md:justify-between ...">  <!-- ... --></div>

Подробнее об использовании вариантов читайте в документации по вариантам.

Авторские права © 2025 Tailwind Labs Inc.·Политика в отношении товарных знаков