一、設置背景顏色:background-color
十六進制 background-color:#ff0000;
英文名稱 background-color:red;
三原色 background-color:rgb(255,0,0)
transparent background-color:transparent;透明
二、設置背景圖片:
1.引入背景圖片:background-image
URL background-image:url("bg.jpg")
none 不設置背景圖片
2.設置背景圖片的平鋪方式:background-repeat
repeat 將背景圖案填滿整個背景。
repeat-x 將背景圖案在水平方向添滿
repeat-y 將背景圖案在垂直方向添滿。
no-repeat 圖案只出現一次。
3.設置背景圖片的位置:background-position
top left 設置背景圖案出現在上左方。
top center 設置背景圖案出現在上方中間。
top right 設置背景圖案出現在上右方。
center left 設置背景圖案出現在中間左方。
center center 設置背景圖案出現在IE中間。
center right 設置背景圖案出現中間右方。
bottom left 設置背景圖案出現在下左方。
bottom 設置背景圖案出現在正下方。
bottom right 設置背景圖案出現在下右方。
也可以通過坐標準確的定位圖片的位置(x,y) x水平方方向的位置 y垂直方向的位置,單位是像素(px)
4.設置背景圖像是否會隨視窗滾動而滾動:background-attachment
scroll 設置背景圖像會隨視窗滾動條的移動而移動(默認)。
fixed 設置背景圖像不會隨視窗滾動條的移動而移動。
背景圖案簡化格式:顏色 背景圖片 repeat attachment position