一般背景用法:
body { background:#eee url(../images/bg.jpg) repeat-x; }
(同一區塊內可同時設定被景色與重複圖片;不可同時兩個背景顏色,或兩圖片背景。)
背景重複:(預設為重複)
body { background-repeat:no-repeat; }
no-repeat:不重複 repeat-x:水平重複 repeat-y:垂直重複 repeat:重複
背景位置: (預設為左上)
body { background-position:top center; }
位置對照表:
body { background:#eee url(../images/bg.jpg) repeat-x; }
(同一區塊內可同時設定被景色與重複圖片;不可同時兩個背景顏色,或兩圖片背景。)
背景重複:(預設為重複)
body { background-repeat:no-repeat; }
no-repeat:不重複 repeat-x:水平重複 repeat-y:垂直重複 repeat:重複
背景位置: (預設為左上)
body { background-position:top center; }
位置對照表:
left | 0% | center | 50% | right | 100% |
top | 0% | top | 0% | top | 0% |
left | 0% | center | 50% | right | 100% |
center | 50% | center | 50% | center | 50% |
left | 0% | center | 50% | right | 100% |
bottom | 50% | bottom | 100% | bottom | 100% |
※可用文字也可用百分比作設定(盡量不要混用,二擇一)
背景固定:(預設為捲動)
body { background-attachment:fixed; }
fixed:固定背景 scroll:捲動背景
全站熱搜
留言列表