# 背景樣式
[TOC]
## 背景顏色
background-color 屬性定義了元素的背景顏色。
頁面的背景顏色使用在body的選擇器中:
```css
body {background-color:#b0c4de;}
```
## 背景圖片
background-image 屬性描述了元素的背景圖像。
默認情況下,背景圖像進行平鋪重復顯示,以覆蓋整個元素實體。
```css
body {background-image:url("../picture/about07.png");}
```
## 背景平鋪重復設置
background-repeat屬性控制背景圖像的平鋪重復效果。

## 背景圖片固定
在默認情況下,組件里的背景圖片會隨著滾動條的滾動而自動滾動,我們要把backgroun-attachment的屬性設為fixed,那么背景圖片就會被固定在該組件中,不會隨滾動條的滾動而移動。
```css
body{background-attachment: fixed;}
```
## 背景圖片的定位
可以利用 `background-position` 屬性改變圖像在背景中的位置。

## 背景圖片大小
background-size屬性指定背景圖片大小。
```css
div
{
background:url(img_flwr.gif);
background-size:80px 60px;
background-repeat:no-repeat;
}
```

## 背景的簡寫屬性
為了簡化這些屬性的代碼,我們可以將這些屬性合并在同一個屬性中.
背景顏色的簡寫屬性為 "background":
當使用簡寫屬性時,屬性值的順序為:
`background-color`
`background-image`
`background-repeat`
`background-attachment`
`background-position`
以上屬性無需全部使用,你可以按照頁面的實際需要使用.