CSS 的差异
A difference in CSS
所以今天我有一个 "semantic question?":
和
有什么区别
#fff
and
#ffffff
在 CSS?
我的意思是,跨浏览器有什么问题吗?
#fff
只是 #ffffff
的简写。它们对浏览器意味着完全相同的东西。
任何 #XXYYZZ
十六进制代码都可以在 CSS 中以这种方式表示,即 #ffccdd
--> #fcd
或 #cc0099
-> #c09
.鉴于这种行为已经存在了几十年,应该没有跨浏览器的困难。
https://www.w3.org/TR/REC-CSS1/#color-units
The format of an RGB value in hexadecimal notation is a '#' immediately followed by either three or six hexadecimal characters. 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 makes sure that white (#ffffff) can be specified with the short notation (#fff) and removes any dependencies on the color depth of the display.
三元组在技术上仍然是十六进制的,但它是一种快捷方式。它所做的只是重复每个值并将其用于 RGB。 #333
变为 #333333
,#abc
变为 #aabbcc
等。
我认为使用它的原因有两个:非常小的 space 节省和 R、G 和 B 的值均匀步进 16,这有助于在低色设备上正确再现颜色(十六进制三元组会给出一个范围4096 个独特的颜色值)。现在它变得不那么有用了,因为这么多设备可以原生显示大量颜色。
所以今天我有一个 "semantic question?":
和
有什么区别#fff
and
#ffffff
在 CSS?
我的意思是,跨浏览器有什么问题吗?
#fff
只是 #ffffff
的简写。它们对浏览器意味着完全相同的东西。
任何 #XXYYZZ
十六进制代码都可以在 CSS 中以这种方式表示,即 #ffccdd
--> #fcd
或 #cc0099
-> #c09
.鉴于这种行为已经存在了几十年,应该没有跨浏览器的困难。
https://www.w3.org/TR/REC-CSS1/#color-units
The format of an RGB value in hexadecimal notation is a '#' immediately followed by either three or six hexadecimal characters. 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 makes sure that white (#ffffff) can be specified with the short notation (#fff) and removes any dependencies on the color depth of the display.
三元组在技术上仍然是十六进制的,但它是一种快捷方式。它所做的只是重复每个值并将其用于 RGB。 #333
变为 #333333
,#abc
变为 #aabbcc
等。
我认为使用它的原因有两个:非常小的 space 节省和 R、G 和 B 的值均匀步进 16,这有助于在低色设备上正确再现颜色(十六进制三元组会给出一个范围4096 个独特的颜色值)。现在它变得不那么有用了,因为这么多设备可以原生显示大量颜色。