HTML DOM Style backgroundColor 屬性
定義和用法
backgroundColor 屬性設置或返回元素的背景顏色。
瀏覽器支持
所有主要瀏覽器都支持backgroundColor 屬性。
注意: IE7及更早的版本不支持"inherit"值。IE8 只有規定了!DOCTYPE 才支持"inherit"。 IE9 支持"inherit"。
語法
設置backgroundColor 屬性:
element .style.backgroundColor="color|inherit|transparent"
返回backgroundColor 屬性:
element .style.backgroundColor
屬性值
值 | 描述 |
---|---|
color | 规定背景颜色。在 CSS 颜色值中寻找可能的颜色值的完整列表。 |
inherit | 背景颜色从父元素继承。 |
transparent | 默认。背景颜色是透明的(基本内容将会穿透)。 |
技術細節
默認值: | transparent |
---|---|
返回值: | 一個代表背景顏色的字符串 |
DOM 版本 | Core Level 1 |
Style對象