# background

background 是一种 CSS 简写属性,用于一次性集中定义各种背景属性,包括 color, image, origin 与 size, repeat 方式等等。

# uni-app x 兼容性

Android iOS web
3.9 4.11 4.0

# 语法

background: [ <bg-layer> , ]* <final-bg-layer>;

# background 的属性值

fixed 背景固定于视口。在分页媒体中,如果没有视口,则“fixed”背景将相对于页面框固定,因此在每一页都会复制。

local 背景相对于元素内容固定:如果元素具有滚动机制,背景将随元素内容滚动。

none 被视为图像层,但不绘制任何内容。

scroll 背景固定于元素自身,不随内容滚动(实际上附加在元素的边框上)。

# 兼容性

# background 的属性值兼容性

Android iOS web
fixed x x 4.0
local x x 4.0
none x x 4.0
scroll x x 4.0

# 浏览器兼容性

Chrome Edge Firefox Opera Safari IE
background √( 1 ) √( 12 ) √( 1 ) √( 3.5 ) √( 1 ) √( 4 )

# 参见