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

# background-repeat

APISummary
## 介绍

`background-repeat` 属性定义背景图 `background-image` (./background-image) 的重复方式。背景图像可以沿着水平、垂直，两个方向重复。

## 使用示例

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

**Entry:** `src/background-repeat`
**Bundle:** `dist/background-repeat.lynx.bundle`

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

const BackgroundRepeat = () => {
  const fixedAreaStyle = {
    width: "100%",
    height: "100%",
    flexDirection: "column" as const,
  };

  const containerStyles = {
    style1: {
      backgroundOrigin: "content-box" as const,
      backgroundPosition: "left top" as const,
      backgroundRepeat: "no-repeat" as const,
    },
    style2: {
      backgroundOrigin: "padding-box" as const,
      backgroundPosition: "50% 50%",
      backgroundRepeat: "repeat-x" as const,
    },
    style3: {
      backgroundOrigin: "border-box" as const,
      backgroundPosition: "30px 40px",
      backgroundRepeat: "repeat" as const,
    },
    style4: {
      backgroundOrigin: "content-box,border-box" as const,
      backgroundPosition: "50% 40px, right bottom",
      backgroundRepeat: "repeat-y,repeat-x" as const,
    },
  };

  return (
    <scroll-view className="root" scroll-orientation="vertical">
      <view className="fixed_area" style={fixedAreaStyle}>
        <view className="container image1" style={containerStyles.style1}></view>
        <view className="container image1" style={containerStyles.style2}></view>
        <view className="container image1" style={containerStyles.style3}></view>
        <view className="container image2" style={containerStyles.style4}></view>
      </view>
    </scroll-view>
  );
};

root.render(<BackgroundRepeat />);

```

v0.11.0



## 语法

```css
background-repeat: repeat-x;
background-repeat: repeat-y;
background-repeat: repeat;
background-repeat: space;
background-repeat: round;
background-repeat: no-repeat;

background-repeat: repeat space;
background-repeat: repeat repeat;
background-repeat: round space;
background-repeat: no-repeat round;
```

### 取值

- 默认值 **repeat** 

  图像会按需重复来覆盖图片所在的区域。最后一个图像可能会被裁剪。

- no-repeat 

  图像不会被重复 (因为背景图片所在的区域可能没有被完全覆盖)。图片的位置由 `background-position` (./background-position) 属性来决定。

- repeat-x 

  图像沿水平方向重复。

- repeat-y 

  图像沿垂直方向重复。

- space 

  图像会尽可能得重复，但不会被裁剪。空白区域会被均匀的分布在图像之间。`background-position` (./background-position) 属性会被忽略。

- round 

  图像会尽可能的重复。为了填充空白区域，图片可能会被拉伸或裁剪。

:::info
`space` 和 `round` 关键字实际的渲染行为与 `repeat` 一致。
:::

## 形式定义

| 初始值 | repeat |
| 适用元素 | all elements |
| 是否支持继承 | no |
| 是否支持动画 | no |


## 形式语法

```
<repeat-style> = repeat-x | repeat-y | [ repeat | space | round | no-repeat ]{1,2}
```

## 与 Web 的区别

- 没有实现 `space` 和 `round` 的渲染行为。
- 不支持全局关键字 `inherit`

## 兼容性

**Compatibility Table**

**Query:** `css.properties.background-repeat`

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

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

**`background-repeat`**

**Specifications:**

