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

APISummary
## 介绍

定义弹性容器中的元件的在主轴的显示是单行（列）或者多行（列），以及在多行（列）情况下的堆叠方向。

## 使用示例

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

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

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

const FlexWrap = () => {
  const item1Style = {
    backgroundColor: "rgba(0,255,0,0.2)" as const,
    flexShrink: 0,
    width: "50%",
  };

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

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

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

  return (
    <scroll-view className="root" scroll-orientation="vertical">
      <view className="fixed_area">
        <text>flex-wrap:nowrap</text>
        <view className="container nowrap">
          <view className="height" style={item1Style}>
            <text>Item One</text>
          </view>
          <view className="height" style={item2Style}>
            <text>Item Two</text>
          </view>
          <view className="height" style={item3Style}>
            <text>Item Three</text>
          </view>
          <view className="height" style={item4Style}>
            <text>Item Four</text>
          </view>
        </view>

        <text>flex-wrap:nowrap</text>
        <view className="container wrap">
          <view className="height" style={item1Style}>
            <text>Item One</text>
          </view>
          <view className="height" style={item2Style}>
            <text>Item Two</text>
          </view>
          <view className="height" style={item3Style}>
            <text>Item Three</text>
          </view>
          <view className="height" style={item4Style}>
            <text>Item Four</text>
          </view>
        </view>

        <text>flex-wrap:wrap-reverse</text>
        <view className="container wrap-reverse">
          <view className="height" style={item1Style}>
            <text>Item One</text>
          </view>
          <view className="height" style={item2Style}>
            <text>Item Two</text>
          </view>
          <view className="height" style={item3Style}>
            <text>Item Three</text>
          </view>
          <view className="height" style={item4Style}>
            <text>Item Four</text>
          </view>
        </view>
      </view>
    </scroll-view>
  );
};

root.render(<FlexWrap />);

```

v0.11.0



## 语法

```css
flex-wrap: nowrap; /* Default value */
flex-wrap: wrap;
flex-wrap: wrap-reverse;
```

### 取值

- `nowrap`

  **默认值**。弹性容器中的元件按照主轴的方向排列，有溢出容器的可能。

- `wrap`

  弹性容器中的元件按照主轴的方向排列，元件会被打断放到不同的行（列）保证主轴方向元件不会溢出容器。

- `wrap-reverse`

  和 `wrap` 的行为一样，但是行（列）的增加方向相反。

## 形式定义

| 初始值 | nowrap |
| 适用元素 | 弹性容器 |
| 是否支持继承 | 否 |
| 是否支持动画 |  |


## 形式语法

```
flex-wrap =
  nowrap        |
  wrap          |
  wrap-reverse
```

## 兼容性

**Compatibility Table**

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

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| flex-wrap | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| nowrap | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| wrap | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| wrap-reverse | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |

**`flex-wrap`**

**Specifications:**

**`nowrap`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/54-flex-wrap.json)

**`wrap`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/54-flex-wrap.json)

**`wrap-reverse`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/54-flex-wrap.json)

