Skip to Content
文档

背景

用于设置背景颜色、渐变和图片样式的 JSX 样式属性。

背景附件

¥Background Attachment

使用 bgAttachment 控制背景图片的附加方式。

¥Use bgAttachment to control the attachment of a background image.

<Box bgAttachment="fixed" bgImage="url(...)" />
属性CSS 属性标记类别
bgAttachment, backgroundAttachmentbackground-attachment*

背景混合模式

¥Background Blend Mode

使用 bgBlendMode 属性控制元素的背景图片如何与其背景颜色混合。

¥Use bgBlendMode prop to control how an element's background image should blend with the its background color.

<Box bgBlendMode="multiply" bgColor="red.200" bgImage="url(...)" />

背景剪辑

¥Background Clip

使用 bgClip 控制背景图片的裁剪。

¥Use bgClip to control the clipping of a background image.

<Box bgClip="border-box" bgImage="url(...)" />
属性CSS 属性标记类别
bgClip, backgroundClipbackground-clip*

背景颜色

¥Background Color

使用 bgbgColorbackgroundColor 属性设置元素的背景颜色。

¥Use bg, bgColor, or backgroundColor props to set the background color of an element.

<Box bg="red.200" />
<Box bgColor="red.200" />

// with opacity modifier
<Box bg="blue.200/30" />
<Box bgColor="blue.200/30" />
属性CSS 属性标记类别
bg, backgroundbackgroundcolors
bgColor, backgroundColorbackground-colorcolors

背景原点

¥Background Origin

使用 bgOriginbackgroundOrigin 控制背景图片的来源。

¥Use bgOrigin or backgroundOrigin to control the origin of a background image.

<Box bgOrigin="border-box" bgImage="url(...)" />
属性CSS 属性标记类别
bgOrigin, backgroundOriginbackground-origin*

背景位置

¥Background Position

用于控制背景图片的 src 和位置的属性。

¥Properties for controlling the src and position of a background image.

<Box bgImage="url(...)" bgPosition="center" />
属性CSS 属性标记类别
bgPosition, backgroundPositionbackground-image*
bgPositionX, backgroundPositionXbackground-image*
bgPositionY, backgroundPositionYbackground-image*

背景重复

¥Background Repeat

使用 bgRepeatbackgroundRepeat 控制背景图片的重复。

¥Use bgRepeat or backgroundRepeat to control the repeat of a background image.

<Box bgRepeat="no-repeat" bgImage="url(...)" />
属性CSS 属性标记类别
bgRepeat, backgroundRepeatbackground-repeat*

背景大小

¥Background Size

使用 bgSizebackgroundSize 控制背景图片的大小。

¥Use bgSize or backgroundSize to control the size of a background image.

<Box bgSize="cover" bgImage="url(...)" />
属性CSS 属性标记类别
bgSize, backgroundSizebackground-size*

背景图片

¥Background Image

使用 bgImagebackgroundImage 设置元素的背景图片。

¥Use bgImage or backgroundImage to set the background image of an element.

<Box bgImage="url(...)" />
<Box bgImage="radial-gradient(circle, #0000 45%, #000f 48%)" />
<Box bgImage="linear-gradient(black, white)" />

// with token reference
<Box bgImage="linear-gradient({colors.red.200}, {colors.blue.200})" />
属性CSS 属性标记类别
bgImage, backgroundImagebackground-imageassets, gradients

背景渐变

¥Background Gradient

用于基于色标创建背景渐变的属性。

¥Properties to create a background gradient based on color stops.

<Box bgGradient="to-r" gradientFrom="red.200" gradientTo="blue.200" />
属性CSS 属性标记类别
bgGradientbackground-imagegradients
textGradientbackground-imagegradients
gradientFrom--gradient-fromcolors
gradientTo--gradient-tocolors
gradientVia--gradient-viacolors

Previous

焦点环

Next

边框