颜色代码六位十六进制字符
One of the most requested capabilities in my early days of web development was the ability to set opacity on elements and even PNG images without the need for browser-specific CSS or hacks. Eventually we got native opacity support and even enjoyed rgba()
, the ability to cite an opacity level with a color.
在我进行Web开发的初期,最需要的功能之一是无需设置特定于浏览器CSS或黑客程序即可在元素甚至PNG图像上设置不透明度的功能。 最终,我们获得了本机不透明度支持,甚至享受了rgba()
,它可以用颜色引用不透明度级别。
While I loved the ability to provide an opacity with color using rgba()
, the use of hexadecimal color had always been ingrained in me, which made the sudden need for rgba conversions annoying. Luckily these days we have 8 digit hex values with allow us to cite an opacity level as the last two characters of the hex value!
虽然我喜欢使用rgba()
为颜色提供不透明性的能力,但十六进制颜色的使用一直根深蒂固,这使对rgba转换的突然需求变得烦人。 幸运的是,这些天我们有8位十六进制值,允许我们将不透明度级别作为十六进制值的最后两个字符!
CSS (The CSS)
Hex implies "six" but the last two digits of the 8 character hex value are the opacity value:
十六进制表示“六个”,但是8个字符的十六进制值的最后两位是不透明度值:
.myElement {
/* { red/50% opacity } */
/* pink of white background */
background: #ff000080;
}
I love that we can use hexidecimal colors with the additional opacity value; needing to convert to rgba to take advantage of opacity was a needless frustration. I owe something to the creator of this API!
我喜欢我们可以将十六进制颜色与附加的不透明度值一起使用; 需要转换为rgba以利用不透明性是不必要的挫败感。 我欠这个API的创建者!
颜色代码六位十六进制字符