Style backgroundColor 属性
页面下方有更多实例。
定义和用法
backgroundColor 属性设置或返回元素的背景颜色。
浏览器支持
表中的数字表示支持该属性的第一个浏览器版本。
| 属性 | |||||
|---|---|---|---|---|---|
| backgroundColor | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
语法
返回 backgroundColor 属性:
object.style.backgroundColor
设置 backgroundColor 属性:
object.style.backgroundColor = "color|transparent|initial|inherit"
属性值
| 值 | 描述 |
|---|---|
| color | 规定背景颜色。在 CSS 颜色值中寻找可能的颜色值的完整列表。 |
| transparent | 默认。背景颜色是透明的(基本内容将会穿透)。 |
| initial | 设置该属性为它的默认值。请参阅 initial |
| inherit | 从父元素继承该属性。请参阅 inherit |
技术细节
| 默认值: | transparent |
|---|---|
| 返回值: | 一个字符串,代表背景颜色的 |
| CSS 版本 | CSS1 |
更多实例
相关页面
CSS 教程: CSS Background
CSS 参考手册: background-color 属性
HTML DOM 参考手册: background 属性
❮ Style 对象
