background:
background: [background-color] [background-image] [background-repeat]
[background-attachment] [background-position] / [ background-size]
[background-origin] [background-clip];
默認值:inherit(no)
值 | 描述 | CSS | Default |
---|---|---|---|
background-color | 規定要使用的背景顏色。 | 1 | transparent |
background-image | 規定要使用的背景圖像。 | 1 | none |
background-repeat | 規定如何重複背景圖像。 | 1 | repeat |
background-attachment | 規定背景圖像是否固定或者隨着頁面的其餘部分滾動。 | 1 | scroll |
background-position | 規定背景圖像的位置。 | 1 | 0% 0% |
background-size | 規定背景圖片的尺寸。 | 3 | auto |
background-origin | 規定背景圖片的定位區域。 | 3 | padding-box |
background-clip | 規定背景的繪製區域。 | 3 | border-box |
eg:
.example {
background: aquamarine url(img.png)
no-repeat
scroll
center center / 50%
content-box content-box;
}
background-origin:繪製區域,表示背景圖片從哪裏開始繪製;
background-clip:顯示區域,從哪裏開始顯示origin繪製的圖片(如果顯示區域小於繪製區域進行裁剪)
background-position:表示繪製區域相對於origin的偏移