浏览器是否默认在后台将 HSL 转换为 RGB?
Do browsers translate HSL to RGB by default in the background?
在显示颜色时,浏览器是否会默认将任何不在 RGB(如 HSL)中的颜色值默认转换为 RGB?我确实在 css 中为颜色 属性 设置了一个 hsl 颜色值,当我检查该值时,该值是 hsl,但我确实在线阅读了浏览器使用 RGB 值可能会发生一些间接转换,所以想到这里问。如果浏览器这样做,是否有任何原因与显示有关?
您好,欢迎使用堆栈溢出,根据 spec:
If the value is translucent, the computed value will be the rgba()
corresponding one. If it isn't, it will be the rgb() corresponding
one.
这意味着无论您输入什么,计算出的值始终是 rgb 或 rgba。而且跟显示没有关系。
在显示颜色时,浏览器是否会默认将任何不在 RGB(如 HSL)中的颜色值默认转换为 RGB?我确实在 css 中为颜色 属性 设置了一个 hsl 颜色值,当我检查该值时,该值是 hsl,但我确实在线阅读了浏览器使用 RGB 值可能会发生一些间接转换,所以想到这里问。如果浏览器这样做,是否有任何原因与显示有关?
您好,欢迎使用堆栈溢出,根据 spec:
If the value is translucent, the computed value will be the rgba() corresponding one. If it isn't, it will be the rgb() corresponding one.
这意味着无论您输入什么,计算出的值始终是 rgb 或 rgba。而且跟显示没有关系。