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

# bottom

APISummary
## 介绍

`bottom` 属性定义了定位元件的下外边距边界与其包含块下边界之间的偏移。定位元件参考 [position 属性](/next/zh/api/css/properties/position.md)。

`bottom` 的效果取决于元件的 `position` 属性：

- 当 `position` 设置为 `absolute` 或 `fixed` 时，`bottom` 属性指定了定位元件下外边距边界与其包含块下边界之间的偏移。

- 当 `position` 设置为 `relative` 时，`bottom` 属性指定了元件的下边界离开其正常位置的偏移。

当 `top` 和 `bottom` 同时指定时，`position` 设置为 `absolute`/`fixed`，并且 `height` 没有被指定或者指定为 `auto` 或 `100%` 的时候，`top` 和 `bottom` 都会生效，在其他情况下，如果 `height` 被限制，则 `top` 属性会优先设置，`bottom` 属性则会被忽略。

## 使用示例

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

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

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

const Bottom = () => {
  const containerStyle = {
    width: "210px",
    height: "210px",
    border: "5px",
    borderColor: "black",
  };

  const firstBoxStyle = {
    position: "absolute" as const,
    bottom: "80px",
    width: "50px",
    height: "50px",
    backgroundColor: "red",
  };

  const secondBoxStyle = {
    position: "fixed" as const,
    bottom: "155px",
    width: "50px",
    height: "50px",
    backgroundColor: "green",
  };

  const thirdBoxStyle = {
    position: "relative" as const,
    bottom: "10px",
    width: "50px",
    height: "50px",
    backgroundColor: "yellow",
  };

  const fourthBoxStyle = {
    width: "50px",
    height: "50px",
    backgroundColor: "blue",
  };

  return (
    <view style={containerStyle}>
      <view style={firstBoxStyle}></view>
      <view style={secondBoxStyle}></view>
      <view style={thirdBoxStyle}></view>
      <view style={fourthBoxStyle}></view>
    </view>
  );
};

root.render(<Bottom />);

```

v0.11.0



## 语法

```css
/* <length> values */
bottom: 3px;
bottom: 2rpx;
bottom: 2.4em;
bottom: 3rem;

bottom: 10%;

/* Keyword value */
bottom: auto;

/* calc */
bottom: calc(1px + 1px);
```

### 取值

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

  一个负的、零或正的 [`<length>`](/next/zh/api/css/data-type/length.md) 值，它表示：

  - 对于绝对定位的元件，它是该元件与包含块底部边缘的距离。
  - 对于相对定位的元件，它是该元件相对于其正常位置向上移动的距离。

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

  [包含块](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Containing_block)高度的百分比。

- `auto`

  **默认值**。

## 形式定义

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


## 形式语法

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

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

## 兼容性

**Compatibility Table**

**Query:** `css.properties.bottom`

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

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

**`bottom`**

**Specifications:**

