background

168 阅读1分钟
background: [background-color] [background-image] [background-repeat]
            [background-attachment] [background-position] / [ background-size]
            [background-origin] [background-clip];

1、background-color

2、background-image

3、background-repeat

repeat
no-repeat
repeat-x
repeat-y
inherit

4、background-attachment

背景图像是否滚动或固定
scroll
fixed
inherit

5、background-position

默认值为0% 0%(水平位置、垂直位置)
10% 0%;
20px 0px;
3left/center/right   top/center/bottom;
如果仅规定了一个值时,另一个值默认为50%
%和position值可以混用,如50%,center

6、position-size

宽度 高度
1100px 100px;(length)
250% 50%;(percent)
3contain 等比例缩放,按照宽度覆盖显示区域,会有空白部分
4、cover 等比例缩放,铺满整个区域,超出部分不显示
只写一个值时,另一个值默认为auto

position/size两个属性之间以斜杠“/”隔开

7、background-origin

背景图像定位区域
1content-box
2border-box
3padding-box 默认值
当background-position为fixed时,该属性不起作用

8、background-clip

背景图绘制区域
1content-box
2border-box 默认值
3padding-box