> 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-shrink

APISummary
## 介绍

定义弹性项目在**主轴**的缩放系数。弹性容器将元件布局完后，如果存在元件溢出，会根据元件的缩放系数比例将对应的元件进行缩放保证元件不会溢出容器。

## 使用示例

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

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

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

const FlexShrink = () => {
  const shrink1Style = {
    backgroundColor: "rgba(0,255,0,0.2)" as const,
    flexShrink: 1,
  };

  const shrink2Style = {
    backgroundColor: "rgba(0,255,0,0.2)" as const,
    flexShrink: 2,
    marginLeft: "10px",
  };

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

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

  return (
    <scroll-view className="root" scroll-orientation="vertical">
      <view className="fixed_area">
        <view className="container">
          <view className="height" style={shrink1Style}>
            <text>flex-shrink:1</text>
          </view>
          <view className="height" style={shrink2Style}>
            <text>flex-shrink:2</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(<FlexShrink />);

```

v0.11.0



## 语法

```css
/* <number> 值 */
flex-shrink: 2;
flex-shrink: 0;
```

### 取值

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

  负值无效，`0` 表示不会缩放，**默认值**为 `1`。

## 形式定义

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


## 形式语法

```
flex-shrink =
  <number [0,∞]>
```

## 兼容性

**Compatibility Table**

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

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

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

**`flex-shrink`**

**Specifications:**

