CSS中的几种颜色表示法,如hsla

html-css07

CSS中的几种颜色表示法,如hsla,第1张

1、用颜色名表示

如:white、red、greenyellow、gold等。

2、用十六进制的颜色值表示(红、绿、蓝)

#FF0000或者#F00

3、用rgb(r,g,b)函数表示

如:rgb(255,255,0)

4、用hsl(Hue,Saturation,Lightness)函数表示(色调、饱和度、亮度)

如:hsl(120,100%,100%),色调0代表红色,120代表绿色,240代表

蓝色

5、用rgba(r,g,b,a)函数表示

其中a表示的是改颜色的透明度,取值范围是0~1,其中0代表完全透明。

6、用hsla(Hue,Saturation,Lightness,alpha)函数表示

色调、饱和度、亮度、透明度

CSS linear-gradient() 函数用于创建一个表示两种或多种颜色线性渐变的图片。其结果属于<gradient>数据类型,是一种特别的<image>数据类型。

linear-gradient( [ <angle>| to <side-or-corner>,]? <color-stop-list>)

  \---------------------------------/ \----------------------------/

    Definition of the gradient line        List of color stops 

where <side-or-corner>= [ left | right ] || [ top | bottom ]

  and <color-stop-list>= [ <linear-color-stop>[, <color-hint>? ]? ]#, <linear-color-stop>

  and <linear-color-stop>= <color>[ <color-stop-length>]?

  and <color-stop-length>= [ <percentage>| <length>]{1,2}

  and <color-hint>= [ <percentage>

栗子:

div {

  background: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet)

}