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

# margin-inline-start

APISummary
## 介绍

在阅读模式的开始方向设置与元件相关联的盒子模型的外边距。
该属性可以为负值。
在 `LTR` 模式下，`margin-inline-start` 等价于 `margin-left`。
在 `RTL` 模式下，`margin-inline-start` 等价于 `margin-right`。

## 使用示例

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

**Entry:** `src/margin-inline-start`
**Bundle:** `dist/margin-inline-start.lynx.bundle`

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

const MarginInlineStart = () => {
  const [rtl, setRtl] = useState(false);

  const containerStyle = {
    direction: rtl ? "rtl" : "ltr" as "rtl" | "ltr",
  };

  const introStyle = {
    marginInlineStart: "50px",
    marginInlineEnd: "10px",
  };

  return (
    <>
      <view className="con" bindtap={() => setRtl(!rtl)} style={containerStyle}>
        <text className="intro" style={introStyle}>1</text>
        <text className="intro2">2</text>
      </view>
      <text>Click above to switch, current {rtl ? "rtl" : "ltr"}</text>
    </>
  );
};

root.render(<MarginInlineStart />);

```

v0.11.0



## 语法

```css
/* <length> values */
margin-inline-start: 0.5em;
margin-inline-start: 0px;
margin-inline-start: 2rpx;

/* <percentage> value */
margin-inline-start: 10%;
```

### 取值

#### `0px`

**默认值**。

#### `<length>`

[`<length>`](/next/zh/api/css/data-type/length.md) 定义了一个确定的宽度值。可以为负值。

#### `<percentage>`

相对于[包含块](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Containing_block)的宽度，以百分比值为外边距。

#### `auto`

让布局流程自己选择一个合适的外边距。

:::info
目前支持在[弹性布局](https://developer.mozilla.org/zh/docs/Web/CSS/CSS_flexible_box_layout)、[网格布局](https://developer.mozilla.org/zh/docs/Web/CSS/CSS_grid_layout)、[线性布局](/next/zh/guide/ui/layout/linear-layout.md)的非 [`position: fixed/absolute/sticky`](/next/zh/api/css/properties/position.md) 子元件中使用。

其中，对于线性布局，仅支持在交叉轴方向上使用 `auto`。
:::

## 形式定义

| 初始值 | 0 |
| 适用元素 | 所有元件 |
| 是否支持继承 | 否 |
| 是否支持动画 |  |
| 百分比 | refer to the width of the containing block |


## 形式语法

```
margin-inline-start =
  <length-percentage>  |
  auto                 |

<length-percentage> =
  <length>      |
  <percentage>
```

## 与 Web 的区别

[mdn: margin-inline-start](https://developer.mozilla.org/zh-CN/docs/Web/CSS/margin-inline-start)

1. 在 Lynx 下，`margin` 任何情况都不会重叠。
2. 目前支持在[弹性布局](https://developer.mozilla.org/zh/docs/Web/CSS/CSS_flexible_box_layout)、[网格布局](https://developer.mozilla.org/zh/docs/Web/CSS/CSS_grid_layout)、[线性布局](/next/zh/guide/ui/layout/linear-layout.md)的非 [`position: fixed/absolute/sticky`](/next/zh/api/css/properties/position.md) 子元件中使用 `auto`。其中，对于线性布局，仅支持在交叉轴方向上的外边距 `auto` 值。

## 兼容性

**Compatibility Table**

**Query:** `css.properties.margin-inline-start`

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| margin-inline-start | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| supported&#95;in&#95;flex&#95;layout | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| supported&#95;in&#95;flex&#95;layout.auto | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| supported&#95;in&#95;linear&#95;layout | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| supported&#95;in&#95;linear&#95;layout.nested&#95;value&#95;1 | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| supported&#95;in&#95;linear&#95;layout.nested&#95;value&#95;2 | No | No | No | No | No | Yes |
| supported&#95;in&#95;grid&#95;layout | Yes (2.1) | Yes (3.4) | Yes (2.1) | Yes (2.1) | Yes (2.1) | Yes |
| supported&#95;in&#95;grid&#95;layout.auto | Yes (2.1) | Yes (3.4) | Yes (2.1) | Yes (2.1) | Yes (2.1) | Yes |

**`margin-inline-start`**

**Specifications:**

**`supported_in_flex_layout`**

Supported in Flexible Box Layout

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/150-margin-inline-start.json)

**`supported_in_flex_layout.auto`**

<code>auto</code>

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/150-margin-inline-start.json)

**`supported_in_linear_layout`**

Supported in Linear Layout

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/150-margin-inline-start.json)

**`supported_in_linear_layout.nested_value_1`**

<code>auto</code> in cross-axis

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/150-margin-inline-start.json)

**`supported_in_linear_layout.nested_value_2`**

<code>auto</code> in main-axis

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/150-margin-inline-start.json)

**`supported_in_grid_layout`**

Supported in Grid Layout

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/150-margin-inline-start.json)

**`supported_in_grid_layout.auto`**

<code>auto</code>

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/150-margin-inline-start.json)

