justify-self

Các tiện ích để kiểm soát cách một mục lưới (grid item) riêng lẻ được căn chỉnh dọc theo trục inline của nó.

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;

Ví dụ

Tự động

Sử dụng tiện ích justify-self-auto để căn chỉnh một mục dựa trên giá trị thuộc tính justify-items của lưới:

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

Đầu (Start)

Sử dụng tiện ích justify-self-start để căn chỉnh một mục lưới về phía đầu trục inline của nó:

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

Giữa (Center)

Sử dụng các tiện ích justify-self-center hoặc justify-self-center-safe để căn chỉnh một mục lưới dọc theo trung tâm trục inline của nó:

Thay đổi kích thước container để xem hành vi căn chỉnh

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>

Khi không có đủ không gian, tiện ích justify-self-center-safe sẽ căn chỉnh mục về phía đầu của container thay vì phía cuối.

Cuối (End)

Sử dụng các tiện ích justify-self-end hoặc justify-self-end-safe để căn chỉnh một mục lưới về phía cuối trục inline của nó:

Thay đổi kích thước container để xem hành vi căn chỉnh

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>

Khi không có đủ không gian, tiện ích justify-self-end-safe sẽ căn chỉnh mục về phía đầu của container thay vì phía cuối.

Kéo dãn (Stretch)

Sử dụng tiện ích justify-self-stretch để kéo dãn một mục lưới để lấp đầy vùng lưới trên trục inline của nó:

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

Thiết kế responsive

Prefix a justify-self utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:

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

Learn more about using variants in the variants documentation.

Copyright © 2025 Tailwind Labs Inc.·Chính sách thương hiệu