background-image

設定物件的背景影像。

語法

{ background-image: sLocation }

可能的值

sLocation

指定下列其中一個值的字串:

none

預設值。下一個父元素的色彩,背景會透過該父元素顯示。

url(sUrl)

背景影像的位置,其中 sUrl 是絕對或相對 URL。

此屬性的預設值為 none 。這不是繼承屬性。

備註

URL 會識別影像檔案。設定背景影像時,您可以設定在無法使用影像時所使用的背景色彩。當影像可以使用時,影像會與背景色彩重疊。

使用 background 複合屬性,即可連同其他背景屬性一併設定此屬性。

範例

下列範例使用 background-image 屬性來指定背景的影像。此範例會呼叫內嵌 (全域) 樣式表,以顯示及隱藏背景影像:

<style>
    .setUrl  { background-image: url(sphere.jpg); }
    .loseUrl { background-image: url(none); }
</style>
</head>
<body>
<span style="font-size: 14;" onmouseover="this.className='setUrl'" onmouseout="this.className='loseUrl'">
. . . 
</span>

標準資訊

您可以在 Cascading Style Sheets (CSS), Level 1 (CSS1) (階層式樣式表 (CSS) 層級 1 (CSS1)) Ee371196.xtlink_newWindow(zh-tw,Expression.40).png 找到此屬性的定義。

適用範圍

a, address, b, big, blockquote, body, button, caption, center, cite, code, col, colgroup, custom, dd, defaults, dfn, div, dl, dt, em, fieldset, form, hn, html, i, iframe, img, input type=button, input type=checkbox, input type=file, input type=image, input type=password, input type=radio, input type=reset, input type=submit, input type=text, li, ol, option, p, s, select, span, sub, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var, xmp

另請參閱

概念

background
background-color
background-position
background-repeat