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

APISummary
## 介绍

`margin-bottom` 属性用于设置元件的底部外边距，允许设置负数值。一个正数值将让它相对于正常流与邻近块更远，而负数值将使得更近。

## 使用示例

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

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

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

const MarginBottom = () => {
  const scrollViewStyle = {
    height: "100%",
  };

  return (
    <scroll-view className="root" scroll-orientation="vertical" style={scrollViewStyle}>
      <view className="con">
        <text
          className="intro"
          style={{
            marginTop: "10px",
            marginBottom: "30px",
          }}
        >
          1
        </text>
        <text className="intro2">
          2
        </text>
      </view>
    </scroll-view>
  );
};

root.render(<MarginBottom />);

```

v0.11.0



## 语法

```css
/* <length> values */
margin-bottom: 50px;
margin-bottom: 0;
margin-bottom: 2rpx;

/* <percentage> value */
margin-bottom: 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 |
| 适用元素 | 所有元件 |
| 是否支持继承 | 否 |
| 是否支持动画 | yes |
| 百分比 | refer to the width of the containing block |


## 形式语法

```
margin-bottom =
  <length-percentage>  |
  auto                 |

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

## 与 Web 的区别

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

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-bottom`

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| margin-bottom | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes | 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 | Yes (3.4) | 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-bottom`**

**Specifications:**

**`supported_in_flex_layout`**

Supported in Flexible Box Layout

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

**`supported_in_flex_layout.auto`**

<code>auto</code>

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

**`supported_in_linear_layout`**

Supported in Linear Layout

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/41-margin-bottom.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/41-margin-bottom.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/41-margin-bottom.json)

**`supported_in_grid_layout`**

Supported in Grid Layout

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

**`supported_in_grid_layout.auto`**

<code>auto</code>

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

