> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# background-image

APISummary
## Introduction

The `background-image` CSS property sets one or more background images on an element. 

The background images are drawn on stacking context layers on top of each other. The first layer specified is drawn as if it is closest to the user. 

The [border](/next/api/css/properties/border.md) of the element are then drawn on top of them, and the [`background-color`](/next/api/css/properties/background-color.md) is drawn beneath them. How the images are drawn relative to the box and its borders is defined by the [`background-clip`](/next/api/css/properties/background-clip.md) and [`background-origin`](/next/api/css/properties/background-origin.md) CSS properties. 


## Examples

**This is an example below: css-api**

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

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

import Flower from "../../resource/bg_flower.gif?inline";
import LynxIcon from "../../resource/lynx.png?inline";

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

  const containerStyles = {
    image1: {
      backgroundImage: `url(${Flower})`,
    },
    image2: {
      backgroundImage: `url(${LynxIcon}), url(${Flower})`,
    },
    gradient1: {
      width: "50%",
      backgroundImage: "linear-gradient(black, green)",
    },
    gradient2: {
      width: "50%",
      backgroundImage: "linear-gradient(green 40%, yellow 30%, blue 70%)",
    },
    gradient3: {
      width: "50%",
      backgroundImage: "linear-gradient(green 40%, yellow 40%, blue 70%)",
    },
    conic: {
      width: "50%",
      height: "100%",
      backgroundImage: "conic-gradient(from 180deg at 50% 50%, red, blue, red)",
    },
    radial1: {
      width: "50%",
      backgroundImage: "radial-gradient(red, green)",
    },
    radial2: {
      width: "50%",
      backgroundImage: "radial-gradient(circle at 100%, #333, #333 50%, #eee 75%, #333 75%)",
    },
    radial3: {
      width: "100%",
      height: "100%",
      backgroundImage: "radial-gradient(ellipse closest-side at 0% 0%, #eabf8a 0%, #c5a35f 100%)",
    },
  };

  return (
    <scroll-view className="root" scroll-orientation="vertical">
      <view className="fixed_area" style={fixedAreaStyle}>
        <view className="container" style={containerStyles.image1}></view>
        <view className="container" style={containerStyles.image2}></view>
        <view className="container">
          <view style={containerStyles.gradient1}></view>
          <view style={containerStyles.conic}></view>
        </view>
        <view className="container">
          <view style={containerStyles.gradient2} />
          <view style={containerStyles.gradient3} />
        </view>
        <view className="container">
          <view style={containerStyles.radial1} />
          <view style={containerStyles.radial2} />
        </view>
        <view className="container">
          <view style={containerStyles.radial3} />
        </view>
      </view>
    </scroll-view>
  );
};

root.render(<BackgroundImage />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.11.0



## Syntax

```css
background-image:
  linear-gradient(to bottom, rgba(255, 255, 0, 0.5), rgba(0, 0, 255, 0.5)),
  url('https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/lynx-website/assets/doc/catfront.png');
```

### Values

Each background image is specified either as the keyword `none` or as an `<image>` value. 


- `none`
  Is a keyword denoting the absence of images.

- `<image>`
  Is an `<image>` denoting the image to display. There can be several of them, separated by commas.
  The supported image formats for background-image are the same as those for image, including jpg, png, gif, webp, etc. Refer to [Supported Image Formats](/next/api/elements/built-in/image.md#compatibility)

## Events

| Name        | Type     | Essential | Description     |
| ----------- | -------- | --------- | --------------- |
| bindbgload  | function | NO        | Loading succeed |
| bindbgerror | function | NO        | Loading failed  |

## Related properties of view

| Name | Type | Default | Example | Essential | Description |
| --- | --- | --- | --- | --- | --- |
| Android skip-redirection | boolean | false | true | NO | It only needs to be set when the background-image uses `<url()>` and is a CDN image. When set to true, the logic of container redirection can be skipped to optimize the related time-consuming |

## Formal definition

| Initial value | none |
| Applies to | all elements |
| Inherited | no |
| Animatable | no |


## Formal Syntax

```
background-image = <bg-image>#

<bg-image> = none | <image>

<image> = <url()> | <gradient>

<url()> = url(<string>)

<gradient> = <linear-gradient()> | <radial-gradient()> | <conic-gradient()>

<linear-gradient()> =
  linear-gradient( [ <angle> | to <side-or-corner> ]? , <color-stop-list> )

<radial-gradient()> =
  radial-gradient( [ <ending-shape> || <size> ]? [ at <position> ]? , <color-stop-list> )

<conic-gradient()> =
  conic-gradient( [ from [ <angle> | <zero> ] ]? [ at <position> ]? , <color-stop-list> )

<side-or-corner> =
  [ left | right ] || [ top | bottom ]

<ending-shape> =
  circle | ellipse

<size> =
  closest-side       |
  farthest-side      |
  closest-corner     |
  farthest-corner    |
  <length>           |
  <length-percentage>{2}

<position> =
  [ left | center | right ] || [ top | center | bottom ]                            |
  [ left | center | right | <length-percentage> ]
    [ top | center | bottom | <length-percentage> ]?                                |
  [ [ left | right ] <length-percentage> ] &&
    [ [ top | bottom ] <length-percentage> ]

<color-stop-list> = <linear-color-stop> ( ',' <linear-color-stop> )*

<linear-color-stop> = <color>

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

```

## Differences from the Web

- `<image>`
  Only support `<url()>` and `<gradient>`.

- `<gradient>`
  Support `linear-gradient`, `radial-gradient`, and `conic-gradient`(since version 3.6).

- `<linear-color-stop>`
  Not support [`linear-color-hint`](https://developer.mozilla.org/zh-CN/docs/Web/CSS/background-image#linear-color-hint)

  Not support [`color-interpolation-method`](https://www.w3.org/TR/css-images-4/#linear-gradients)

  Not support [`<length>`](/next/api/css/data-type/length.md) value for position

## Compatibility

**Compatibility Table**

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

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/98-background-image.json) · [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/background-image)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| background-image | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| conic-gradient | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes (3.6) | Yes |

**`background-image`**

**Specifications:**

**`conic-gradient`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/98-background-image.json) · [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/gradient/conic-gradient)

**Specifications:**

