网页设计

Colors HSL and HSLA

时间:2024-05-12 17:09:10   作者:郑士利   来源:正势利   阅读:242   评论:0
内容摘要:https://www.w3schools.com/colors/colors_hsl.aspHSLColorsHSLcolorvaluesaresupportedinEdge,Chrome,Firefox,Safari,Opera10+,andinIE9+.HSLstandsforHue,Saturation,and...

https://www.w3schools.com/colors/colors_hsl.asp

HSL Colors

HSL color values are supported in Edge, Chrome, Firefox, Safari, Opera 10+, and in IE9+.

HSL stands for Hue, Saturation, and Lightness.

HSL color values are specified with:

hsl(hue, saturation, lightness)

Hue

Hue is a degree on the color wheel from 0 to 360. 0 (or 360) is red, 120 is green, 240 is blue.

Saturation

Saturation can be described as the intensity of a color. It is a percentage value from 0% to 100%.

100% is full color, no shades of gray.

50% is 50% gray, but you can still see the color.

0% is completely gray; you can no longer see the color.

Lightness

The lightness of a color can be described as how much light you want to give the color, where 0% means no light (dark), 50% means 50% light (neither dark nor light), and 100% means full light.

Try it Yourself

HSL color values are supported in all major browsers.

Example

<style>

div {

   background-color: hsl(170, 50%, 50%);

   color: hsl(0, 50%, 50%);

}

</style>

HSLA Color Values

HSLA color values are an extension of HSL color values, with an Alpha channel - which specifies the opacity for a color.

An HSLA color value is specified with:

hsla(hue, saturation, lightness, alpha)

The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (not transparent at all):

Example

<h1 style="background-color:hsla(120, 100%, 50%, 0.2);">hsla(0, 100%, 50%, 0.2)</h1>

<h1 style="background-color:hsla(120, 100%, 50%, 0.4);">hsla(0, 100%, 50%, 0.4)</h1>

<h1 style="background-color:hsla(120, 100%, 50%, 0.6);">hsla(0, 100%, 50%, 0.6)</h1>

<h1 style="background-color:hsla(120, 100%, 50%, 0.8);">hsla(0, 100%, 50%, 0.8)</h1>

逝者如斯,不舍昼夜作者QQ及微信:49922779 点击这里给我发消息


相关评论
郑士点利 | 必应 | DeepSeek | 豆包 | H-K9L | 3cn.cn | 郑有钱 | 郑有富 | 22钛 | 光学显微镜 | 显微镜与你 | 光学棱镜 | 40锆 | 79金 | 47银 | 67钬 | 73钽 | 19钾

该站用来记录个人生活的笔记,内容部分资料来源于网络,如有侵权,请联系删除。(QQ/微信:49922779点击这里给我发消息 邮箱:ZSL@zhengshili.com)

  浙ICP备2025212358号