弹性盒子与网格
控制flex项目如何生长的工具类。
Class | Styles |
---|---|
grow | flex-grow: 1; |
grow-<number> | flex-grow: <number>; |
grow-[<value>] | flex-grow: <value>; |
grow-(<custom-property>) | flex-grow: var(<custom-property>); |
使用 grow
来允许 flex 项目生长,以填充任何可用空间:
<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
,使 flex 项目根据其生长因子按比例生长,从而填充相对彼此的可用空间:
<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
来防止 flex 项目生长:
<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 flex 生长因子 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.