1. 弹性盒与网格
  2. flex-grow(弹性增长)

弹性盒与网格

flex-grow

用于控制 flex 项目如何扩展的工具类。

ClassStyles
grow
flex-grow: 1;
grow-<number>
flex-grow: <number>;
grow-[<value>]
flex-grow: <value>;
grow-(<custom-property>)
flex-grow: var(<custom-property>);

示例

允许项目扩展

使用 grow 允许 flex 项目扩展以填充可用空间:

01
02
03
<div class="flex ...">  <div class="size-14 flex-none ...">01</div>  <div class="size-14 grow ...">02</div>  <div class="size-14 flex-none ...">03</div></div>

基于比例因子扩展项目

使用 grow-<number> 工具类(如 grow-3)让弹性项目根据其扩展因子按比例增长,使它们能够相对于彼此填充可用空间:

01
02
03
<div class="flex ...">  <div class="size-14 grow-3 ...">01</div>  <div class="size-14 grow-7 ...">02</div>  <div class="size-14 grow-3 ...">03</div></div>

防止元素扩展

使用 grow-0 阻止弹性项目扩展:

01
02
<div class="flex ...">  <div class="size-14 grow ...">01</div>  <div class="size-14 grow-0 ...">02</div>  <div class="size-14 grow ...">03</div></div>

使用自定义值

Use the grow-[<value>] syntax to set the 弹性扩展因子 based on a completely custom value:

<div class="grow-[25vw] ...">  <!-- ... --></div>

For CSS variables, you can also use the grow-(<custom-property>) syntax:

<div class="grow-(--my-grow) ...">  <!-- ... --></div>

This is just a shorthand for grow-[var(<custom-property>)] that adds the var() function for you automatically.

响应式设计

Prefix a flex-grow utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:

<div class="grow md:grow-0 ...">  <!-- ... --></div>

Learn more about using variants in the variants documentation.

Copyright © 2025 Tailwind Labs Inc.·Trademark Policy