弹性和网格
用于控制单个网格项如何沿其内联轴对齐的实用程序。
使用 justify-self-auto
根据网格的 justify-items
属性的值对齐项目:
<div class="grid justify-items-stretch ...">
<!-- ... -->
<div class="justify-self-auto ...">02</div>
<!-- ... -->
<!-- ... -->
<!-- ... -->
<!-- ... -->
</div>
使用 justify-self-start
将网格项与其内联轴的起点对齐:
<div class="grid justify-items-stretch ...">
<!-- ... -->
<div class="justify-self-start ...">02</div>
<!-- ... -->
<!-- ... -->
<!-- ... -->
<!-- ... -->
</div>
使用 justify-self-center
将网格项沿其内联轴的中心对齐:
<div class="grid justify-items-stretch ...">
<!-- ... -->
<div class="justify-self-center ...">02</div>
<!-- ... -->
<!-- ... -->
<!-- ... -->
<!-- ... -->
</div>
使用 justify-self-end
将网格项与其内联轴的末尾对齐:
<div class="grid justify-items-stretch ...">
<!-- ... -->
<div class="justify-self-end ...">02</div>
<!-- ... -->
<!-- ... -->
<!-- ... -->
<!-- ... -->
</div>
使用 justify-self-stretch
拉伸网格项以填充其内联轴上的网格区域:
<div class="grid justify-items-start ...">
<!-- ... -->
<div class="justify-self-stretch ...">02</div>
<!-- ... -->
<!-- ... -->
<!-- ... -->
<!-- ... -->
</div>
Tailwind 允许您使用变体修饰符有条件地在不同状态下应用实用程序类。例如,使用 hover:justify-self-end
来仅 在 hover应用 justify-self-end
.
<div class="justify-self-start hover:justify-self-end">
<!-- ... -->
</div>
详细了解, 请参考 Hover, Focus, & Other States 文档.
您还可以使用变体修饰符来定位媒体查询,例如响应式断点、暗模式、首选减少运动等。例如, 使用 md:justify-self-end
来应用 justify-self-end
程序,适用于中等屏幕尺寸及以上。
<div class="justify-self-start md:justify-self-end">
<!-- ... -->
</div>