Skip to content

Justify Items 项目对齐

用于控制网格项目沿其内联轴对齐的实用程序。

ClassProperties

基本用法

Start 开始

使用 justify-items-start 来使网格项沿其内联轴的起始位置对齐:

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

End 末尾

使用 justify-items-end 来使网格项沿其内联轴的末尾位置对齐:

01
02
03
04
05
06
html
<div class="grid justify-items-end ...">
  <div>01</div>
  <div>02</div>
  <div>03</div>
  <div>04</div>
  <div>05</div>
  <div>06</div>
</div>

Center 居中

使用 justify-items-center 来使网格项沿其内联轴对齐:

01
02
03
04
05
06
html
<div class="grid justify-items-center ...">
  <div>01</div>
  <div>02</div>
  <div>03</div>
  <div>04</div>
  <div>05</div>
  <div>06</div>
</div>

Stretch 伸展

使用 justify-items-stretch 来沿着它们的内联轴拉伸项目:

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

有条件地应用

悬停,焦点和其他状态

Tailwind 允许您使用变体修饰符在不同状态下有条件地应用实用程序类。例如,使用 hover:justify-items-center 只在悬停时应用 justify-items-center 实用程序。

html
<div class="grid justify-items-start hover:justify-items-center">
  <!-- ... -->
</div>

要查看所有可用状态修饰符的完整列表,请查看悬停,焦点和其他状态文档。

断点和媒体查询

您还可以使用变体修饰符来定位媒体查询,如响应式断点、暗模式、偏好减少动作等。例如,使用 md:justify-items-center 仅在中等屏幕尺寸及以上应用 justify-items-center 实用程序。

html
<div class="grid justify-items-start md:justify-items-center">
  <!-- ... -->
</div>

要了解更多信息,请查看有关响应式设计深色模式其他媒体查询修改器的文档。

Released under the MIT License.