background-color
介绍
background-color
会设置元素的背景色,属性的值为颜色<color>
。
取值
<color>
描述背景颜色。该属性只能指定一个颜色值。默认值 transparent
样例:
/* Keyword values */
background-color: red;
/* Hexadecimal value */
background-color: #bbff00;
/* RGB value */
background-color: rgb(255, 255, 128);
/* HSLA value */
background-color: hsla(50, 33%, 25%, 0.75);
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
标准化语法
<bg-color> = <rgb()> | <rgba()> | <hsl()> | <hsla()> | <hex-color> | <named-color>
1
与 Web 的区别
- 不支持特殊关键字,例如
currentcolor
- 不支持全局关键字,例如
inherit
、initial