Open nfssuzukaze opened 3 years ago
background-image
local
scroll
fixed
background-clip
background-origin
length
percentage
auto
keyword
contain
background-color
cover
有两个属性值,第一个值表示水平方向,第二个值表示垂直方向
repeat
space
round
background-attachment(设置
background-image
的固定方式)属性值
local
(相对于元素的内容固定,可以随着元素的内容滚动而滚动)scroll
(相对于元素本身固定)fixed
(相对于浏览器可视区设置的,元素本身只负责呈现视口内(与background-clip
和background-origin
有关)的背景)background-size(设置
background-image
的大小)属性值
length
与percentage
都可以用来设置宽高,配合auto
使用可以达到按图片比例缩放的效果keyword
contain
:一般用来将比元素背景区大的图片缩小到背景区能完全容纳(很有可能会产生空白,若有background-color
,则由background-color
来进行填充)cover
:将图片按原比例尽量缩放至刚好覆盖整个背景区(但因为是按比例缩放,所以如有超出的部分,则被裁剪)background-repeat(
background-image
的重复方式)属性值
有两个属性值,第一个值表示水平方向,第二个值表示垂直方向
repeat
不缩放图片,没有空隙,填充整行或整列的空间,图片多余的部分被裁剪掉space
不缩放图片与裁剪(除非图片大出背景区),使多出的空隙填充在background-image
之间round
用缩放图片来填充整行或整列的空间