background-color

416 阅读1分钟

background-color

设置元素的背景色,

  • transparent(默认值)
  • 关键字
  • RGB
  • currentcolor

transparent

默认background的取值为transparent,即透明,这俩种写法是等价的 code.png

关键字

即设置颜色的单词 code.png

background-color可以设置多个值吗? 像这样设置:

RGB

rgb即三原色,red,green,blue,rgba 中的 a 为 alpha 透明度

十六进制写法

code.png

函数符写法

code.png

currentcolor

继承父元素的color,如果父元素没有color属性,则值为rgb(0,0,0)

code.png

background可不可以设置多个值?

code.png 答: 不可以background-color设置多个值,会导致该属性失效