> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# flex-grow

APISummary
## 介绍

定义弹性项目在**主轴**的增长系数。这个属性规定了 `flex-grow` 项在弹性容器中分配剩余空间的相对比例。主尺寸是项的宽度或高度，这取决于 [`flex-direction`](/next/zh/api/css/properties/flex-direction.md) 值。

剩余空间是弹性容器的大小减去所有弹性项目的大小加起来的大小。如果所有的兄弟项目都有相同的 `flex-grow` 系数，那么所有的项目将剩余空间按相同比例分配，否则将根据不同的 `flex-grow` 定义的比例进行分配。

`flex-grow` 与其他的 flex 属性 [`flex-shrink`](/next/zh/api/css/properties/flex-shrink.md) 和 [`flex-basis`](/next/zh/api/css/properties/flex-basis.md) 一起使用，通常使用 [flex](/next/zh/api/css/properties/flex.md) 速记来定义，以确保所有的值都被设置。

## 使用示例

**下面是一个示例: css-api**

**Entry:** `src/flex-grow`
**Bundle:** `dist/flex-grow.lynx.bundle`

```tsx
import { root } from "@lynx-js/react";
import "./index.scss";

const FlexGrow = () => {
  const grow1Style = {
    backgroundColor: "rgba(0,255,0,0.2)" as const,
    flexGrow: 1,
  };

  const item2Style = {
    backgroundColor: "rgba(0,0,255,0.2)" as const,
    flexGrow: 0,
    marginLeft: "10px",
  };

  const item3Style = {
    backgroundColor: "rgba(255,0,0,0.2)" as const,
    flexGrow: 0,
    marginLeft: "10px",
  };

  return (
    <scroll-view className="root" scroll-orientation="vertical">
      <view className="fixed_area">
        <view className="container">
          <view className="height" style={grow1Style}>
            <text>flex-grow:1</text>
          </view>
          <view className="height" style={item2Style}>
            <text>Item Two</text>
          </view>
          <view className="height" style={item3Style}>
            <text>Item Three</text>
          </view>
        </view>
      </view>
    </scroll-view>
  );
};

root.render(<FlexGrow />);

```

v0.11.0



## 语法

```css
/* <number> 值 */
flex-grow: 3;
flex-grow: 0.6;
```

### 取值

- [`<number>`](/next/zh/api/css/data-type/number.md)

  负值无效，**默认值**为 `0`。

## 形式定义

| 初始值 | 0 |
| 适用元素 | flex items |
| 是否支持继承 | 否 |
| 是否支持动画 | yes |


## 形式语法

```
flex-grow = <number>
```

## 兼容性

**Compatibility Table**

**Query:** `css.properties.flex-grow`

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/50-flex-grow.json) · [MDN](https://developer.mozilla.org/zh-CN/docs/Web/CSS/flex-grow)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| flex-grow | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |

**`flex-grow`**

**Specifications:**

