背景(Background)
backgroundとは、背景に関する設定を一括して指定するためのプロパティです。
具体的には、background-attachment、background-color、background-image、background-position、background-repeatで指定する値を任意の順序でスペースで区切って指定します。
| 書式 | background: <value:値> |
|---|---|
| 値 | <background-color> ||<background-image>
||<background-repeat> | |<background-attachment> ||<background-position> |
| 初期値 | 未定義 |
| 適用要素 | 全ての要素 |
| 継承性 | 不可 |
backgroundプロパティーは、より特殊な背景関連プロパティ−の短縮型です。
background宣言の例を以下にあげます:
BODY { background: white url(http://www.htmlhelp.com/foo.gif) }
BLOCKQUOTE { background: #7fffd4 }
P { background: url(../backgrounds/pawn.png) #f0f8ff fixed }
TABLE { background: #0c0 url(leaves.jpg) no-repeat bottom right }
BLOCKQUOTE { background: #7fffd4 }
P { background: url(../backgrounds/pawn.png) #f0f8ff fixed }
TABLE { background: #0c0 url(leaves.jpg) no-repeat bottom right }
特定化されていない値は、その初期値を受け取ります。
例えば上のはじめから三つの規則では、background-positionプロパティーは 0% 0%に設定されます。
ユーザーのスタイル・シートとの衝突を避ける手助けとして、backgroundとcolorは必ず一緒に特定されるべきです。
SAMPLE