gpt4 book ai didi

css - 为什么 3 位十六进制 css 颜色会按照它们的方式转换为 6?

转载 作者:技术小花猫 更新时间:2023-10-29 11:46:02 26 4
gpt4 key购买 nike

我知道将 3 位十六进制 css 颜色转换为 6 位代码的方法是将每个十六进制数字复制一次,如下所示。

#ABC === #AABBCC

为什么会这样?为什么 #ABC 不等同于 #A0B0C0

最佳答案

来自 W3C 规范:

The three-digit RGB notation (#rgb) is converted into six-digit form (#rrggbb) by replicating digits, not by adding zeros. For example, #fb0 expands to #ffbb00. This ensures that white (#ffffff) can be specified with the short notation (#fff) and removes any dependencies on the color depth of the display.

您可以在这里阅读更多相关信息:http://www.w3.org/TR/css3-color/

关于css - 为什么 3 位十六进制 css 颜色会按照它们的方式转换为 6?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11459405/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com