1. Flexbox & Grid
  2. grid-auto-flow

Flexbox & Grid

grid-auto-flow

用于控制网格中元素如何自动放置的实用工具。

类名样式
grid-flow-row
grid-auto-flow: row;
grid-flow-col
grid-auto-flow: column;
grid-flow-dense
grid-auto-flow: dense;
grid-flow-row-dense
grid-auto-flow: row dense;
grid-flow-col-dense
grid-auto-flow: column dense;

示例

基本示例

使用类似 grid-flow-colgrid-flow-row-dense 这样的实用工具来控制网格布局中自动放置算法的工作方式

01
02
03
04
05
<div class="grid grid-flow-row-dense grid-cols-3 grid-rows-3 ...">
<div class="col-span-2">01</div>
<div class="col-span-2">02</div>
<div>03</div>
<div>04</div>
<div>05</div>
</div>

响应式设计

前缀a grid-auto-flow 实用工具 使用断点变体,例如 md:,以仅在以下情况下应用该实用工具中等 屏幕尺寸及以上

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

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

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