1. Flexbox & Grid
  2. place-self

Flexbox & Grid

place-self

用于控制单个项目如何同时对齐和对齐的实用工具。

样式
place-self-auto
place-self: auto;
place-self-start
place-self: start;
place-self-end
place-self: end;
place-self-center
place-self: center;
place-self-stretch
place-self: stretch;

示例

自动

使用 place-self-auto 根据容器的 place-items 属性的值对齐项目

01
02
03
04
05
06
<div class="grid grid-cols-3 gap-4 ...">  <div>01</div>  <div class="place-self-auto ...">02</div>  <div>03</div>  <div>04</div>  <div>05</div>  <div>06</div></div>

开始

使用 place-self-start 在两个轴上将项目对齐到起点

01
02
03
04
05
06
<div class="grid grid-cols-3 gap-4 ...">  <div>01</div>  <div class="place-self-start ...">02</div>  <div>03</div>  <div>04</div>  <div>05</div>  <div>06</div></div>

居中

使用 place-self-center 在两个轴上将项目对齐到中心

01
02
03
04
05
06
<div class="grid grid-cols-3 gap-4 ...">  <div>01</div>  <div class="place-self-center ...">02</div>  <div>03</div>  <div>04</div>  <div>05</div>  <div>06</div></div>

结束

使用 place-self-end 在两个轴上将项目对齐到末尾

01
02
03
04
05
06
<div class="grid grid-cols-3 gap-4 ...">  <div>01</div>  <div class="place-self-end ...">02</div>  <div>03</div>  <div>04</div>  <div>05</div>  <div>06</div></div>

拉伸

使用 place-self-stretch 在两个轴上拉伸项目

01
02
03
04
05
06
<div class="grid grid-cols-3 gap-4 ...">  <div>01</div>  <div class="place-self-stretch ...">02</div>  <div>03</div>  <div>04</div>  <div>05</div>  <div>06</div></div>

响应式设计

前缀a place-self 工具类 带有一个像 md: 这样的断点变体,以便仅在中等 屏幕尺寸及以上应用该工具类

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

变体文档中了解有关使用变体的更多信息。

版权所有 © 2025 Tailwind Labs Inc.·商标政策