Justify Self 自我调整
用于控制单个网格项沿其内联轴对齐的实用程序。
| Class | Properties |
|---|
基本用法
Auto 自动
使用 justify-self-auto 根据网格的 justify-items 属性的值来对齐项目:
01
02
03
04
05
06
html
<div class="grid justify-items-stretch ...">
<!-- ... -->
<div class="justify-self-auto ...">02</div>
<!-- ... -->
<!-- ... -->
<!-- ... -->
<!-- ... -->
</div>Start 开始
使用 justify-self-start 将网格项对齐到其内联轴的起始位置:
01
02
03
04
05
06
html
<div class="grid justify-items-stretch ...">
<!-- ... -->
<div class="justify-self-start ...">02</div>
<!-- ... -->
<!-- ... -->
<!-- ... -->
<!-- ... -->
</div>Center 居中
使用 justify-self-center 将网格项沿其内联轴的中心对齐:
01
02
03
04
05
06
html
<div class="grid justify-items-stretch ...">
<!-- ... -->
<div class="justify-self-center ...">02</div>
<!-- ... -->
<!-- ... -->
<!-- ... -->
<!-- ... -->
</div>End 末尾
使用 justify-self-end 将网格项对齐到其内联轴的末尾:
01
02
03
04
05
06
html
<div class="grid justify-items-stretch ...">
<!-- ... -->
<div class="justify-self-end ...">02</div>
<!-- ... -->
<!-- ... -->
<!-- ... -->
<!-- ... -->
</div>Stretch 伸展
使用 justify-self-stretch 来拉伸网格项,以填充其内联轴上的网格区域:
01
02
03
04
05
06
html
<div class="grid justify-items-start ...">
<!-- ... -->
<div class="justify-self-stretch ...">02</div>
<!-- ... -->
<!-- ... -->
<!-- ... -->
<!-- ... -->
</div>有条件地应用
悬停,焦点和其他状态
Tailwind 允许您使用变体修饰符在不同状态下有条件地应用实用程序类。例如,使用 hover:justify-self-end 只在悬停时应用 justify-self-end 实用程序。
html
<div class="justify-self-start hover:justify-self-end">
<!-- ... -->
</div>要查看所有可用状态修饰符的完整列表,请查看悬停,焦点和其他状态文档。
断点和媒体查询
您还可以使用变体修饰符来定位媒体查询,如响应式断点、暗模式、偏好减少动作等。例如,使用 md:justify-self-end 仅在中等屏幕尺寸及以上应用 justify-self-end 实用程序。
html
<div class="justify-self-start md:justify-self-end">
<!-- ... -->
</div>