1. 弹性盒 & 网格
  2. 弹性方向

Quick reference

属性
flex-rowflex-direction: row;
flex-row-reverseflex-direction: row-reverse;
flex-colflex-direction: column;
flex-col-reverseflex-direction: column-reverse;

基本用法(Basic usage)

行(Row)

使用 flex-row 将弹性项目沿与文本相同的方向水平排列:

🌐 Use flex-row to position flex items horizontally in the same direction as text:

01
02
03
<div class="flex flex-row ...">
  <div>01</div>
  <div>02</div>
  <div>03</div>
</div>

行颠倒(Row reversed)

使用 flex-row-reverse 将弹性项目沿相反方向水平排列:

🌐 Use flex-row-reverse to position flex items horizontally in the opposite direction:

01
02
03
<div class="flex flex-row-reverse ...">
  <div>01</div>
  <div>02</div>
  <div>03</div>
</div>

列(Column)

使用 flex-col 垂直定位弹性项目:

🌐 Use flex-col to position flex items vertically:

01
02
03
<div class="flex flex-col ...">
  <div>01</div>
  <div>02</div>
  <div>03</div>
</div>

列颠倒(Column reversed)

使用 flex-col-reverse 将弹性项目垂直定位到相反方向:

🌐 Use flex-col-reverse to position flex items vertically in the opposite direction:

01
02
03
<div class="flex flex-col-reverse ...">
  <div>01</div>
  <div>02</div>
  <div>03</div>
</div>

有条件申请

悬停、聚焦及其他状态

Tailwind 允许你使用变体修饰符在不同状态下有条件地应用工具类。例如,使用hover:flex-row 仅在 hover 时应用 flex-row 工具。

<div class="flex flex-col hover:flex-row">
  <!-- ... -->
</div>

有关所有可用状态修饰符的完整列表,请查看悬停、聚焦、以及其他状态 文档。

断点和媒体查询

你还可以使用变体修饰符来定位媒体查询,例如响应式断点、暗黑模式、首选减少运动等。例如,使用 md:flex-row 仅在中等屏幕尺寸及以上时应用 flex-row 工具。

<div class="flex flex-col md:flex-row">
  <!-- ... -->
</div>

要了解更多信息,请查看有关 响应式设计暗黑模式、以及 其他媒体查询修饰符 的文档。