1. Flexbox и Grid
  2. justify-self

Flexbox и Grid

justify-self

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

ClassStyles
justify-self-auto
justify-self: auto;
justify-self-start
justify-self: start;
justify-self-center
justify-self: center;
justify-self-center-safe
justify-self: safe center;
justify-self-end
justify-self: end;
justify-self-end-safe
justify-self: safe end;
justify-self-stretch
justify-self: stretch;

Примеры

Auto

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

01
02
03
04
05
06
<div class="grid justify-items-stretch ...">  <!-- ... -->  <div class="justify-self-auto ...">02</div>  <!-- ... --></div>

Start

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

01
02
03
04
05
06
<div class="grid justify-items-stretch ...">  <!-- ... -->  <div class="justify-self-start ...">02</div>  <!-- ... --></div>

Center

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

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

justify-self-center

01
02
03

justify-self-center-safe

01
02
03
justify-self-center
<div class="grid justify-items-stretch ...">  <!-- ... -->  <div class="justify-self-center ...">02</div>  <!-- ... --></div>
justify-self-center-safe
<div class="grid justify-items-stretch ...">  <!-- ... -->  <div class="justify-self-center-safe ...">02</div>  <!-- ... --></div>

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

End

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

Resize the container to see the alignment behavior

justify-self-end

01
02
03

justify-self-end-safe

01
02
03
justify-self-end
<div class="grid justify-items-stretch ...">  <!-- ... -->  <div class="justify-self-end ...">02</div>  <!-- ... --></div>
justify-self-end-safe
<div class="grid justify-items-stretch ...">  <!-- ... -->  <div class="justify-self-end-safe ...">02</div>  <!-- ... --></div>

When there is not enough space available, the justify-self-end-safe utility will align the item to the start of the container instead of the end.

Stretch

Use the justify-self-stretch utility to stretch a grid item to fill the grid area on its inline axis:

01
02
03
04
05
06
<div class="grid justify-items-start ...">  <!-- ... -->  <div class="justify-self-stretch ...">02</div>  <!-- ... --></div>

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

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

<div class="justify-self-start md:justify-self-end ...">  <!-- ... --></div>

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

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