HSL
今天在codecademy
上学习,发现了一个以前不曾遇见的知识点(是自己看的太少啦),特此记录下来。在codecademy
上是这样解释HSL的:
The current revision of CSS, CSS3 (at the time of this writing), introduces a new way to specify colors using HSL colors.
HSL stands for Hue, Saturation, and Lightness. Specifically, this is what each means:
Hue - the technical term that describes what we understand as "color." In HSL, hue is represented on a color wheel. It can take on values between 0 and 360.
Saturation - the amount of gray in a given color. In HSL, saturation is specified using a percentage between 0% and 100%. The percentage 0% represents a shade of gray, whereas 100% represents full saturation.
Lightness - the amount of white in a given color. Similar to saturation, lightness is specified using a percentage between 0% and 100%. The percentage 0% represents black, whereas 100% represents white. 50% is normal.
You can use HSL colors in your CSS like this:
h1 {
color: hsl(182, 20%, 50%);
}
后来去翻译、查阅了一些资料。HSL是H、S、L:
H:
Hue(色调)。0(或360)表示红色,120表示绿色,240表示蓝色,也可取其他数值来指定颜色。取值为:0 - 360
S:
Saturation(饱和度)。取值为:0.0% - 100.0%
L:
Lightness(亮度)。取值为:0.0% - 100.0%
它和rgb很相似。rgba是包括了透明度的。
而hsl也能拥有透明度,写作hsla()。
注意:由于HSL是CSS3的一部分,旧版浏览器可能不支持。