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

APISummary
## 介绍

定义弹性容器中的元件排列方向，该方向作为弹性容器的布局主轴，另外一个方向称为交叉轴。

## 使用示例

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

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

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

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

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

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

  return (
    <scroll-view className="root" scroll-orientation="vertical">
      <view className="fixed_area">
        <view className="row">
          <view style={greenStyle}></view>
          <view style={blueStyle}></view>
          <view style={redStyle}></view>
        </view>

        <view className="row-reverse">
          <view style={greenStyle}></view>
          <view style={blueStyle}></view>
          <view style={redStyle}></view>
        </view>

        <view className="container column">
          <view style={greenStyle}></view>
          <view style={blueStyle}></view>
          <view style={redStyle}></view>
        </view>

        <view className="container column-reverse">
          <view style={greenStyle}></view>
          <view style={blueStyle}></view>
          <view style={redStyle}></view>
        </view>
      </view>
    </scroll-view>
  );
};

root.render(<FlexDirection />);

```

v0.11.0



请注意，值 `row` 和 `row-reverse` 受弹性容器的 [`direction`](/next/zh/api/css/properties/direction.md) 影响。如果它的 `direction` 属性是 `ltr`，`row` 表示从左到右定向的水平轴，而 `row-reverse` 表示从右到左; 如果 `dir` 属性是 `rtl` 或者 `lynx-rtl`，`row` 表示从右到左定向的轴，而 `row-reverse` 表示从左到右。

## 语法

```css
/* The direction text is laid out in a line */
flex-direction: row;

/* Like <row>, but reversed */
flex-direction: row-reverse;

/* The direction in which lines of text are stacked */
flex-direction: column;

/* Like <column>, but reversed */
flex-direction: column-reverse;
```

### 取值

- `row`

  **默认值**。flex 容器中的元件按照文本方向进行布局。主轴的方向和文本方向一致。

- `row-reverse`

  和 `row` 的表现一致，但是置换了主轴起点和主轴终点。

- `column`

  flex 容器中的元件按照书写模式的方向进行布局，主轴的方向和书写模式的方向一致。

- `column-reverse`

  和 `column` 表现一致，但是置换了主轴起点和主轴终点。

## 形式定义

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


## 形式语法

```
flex-direction =
  row             |
  row-reverse     |
  column          |
  column-reverse
```

## 兼容性

**Compatibility Table**

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

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

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

**`flex-direction`**

**Specifications:**

