Firefox parsing 4 digit hex color values as rgba

前端 未结 2 403
孤独总比滥情好
孤独总比滥情好 2021-01-28 03:41

Recently observed (by accident) that Firefox (I\'m using v49) is parsing 4 digit hex colors as rgba. Reading up on the CSS spec, I don\'t see any mention of support for this an

相关标签:
2条回答
  • 2021-01-28 04:03

    This is new to Color level 4 (which is why it doesn't appear in level 3) and was indeed shipped in Firefox 49:

    8 digits
    The first 6 digits are interpreted identically to the 6-digit notation. The last pair of digits, interpreted as a hexadecimal number, specifies the alpha channel of the color, where 00 represents a fully transparent color and ff represent a fully opaque color.

    4 digits
    This is a shorter variant of the 8-digit notation, "expanded" in the same way as the 3-digit notation is. The first digit, interpreted as a hexadecimal number, specifies the red channel of the color, where 0 represents the minimum value and f represents the maximum. The next three digits represent the green, blue, and alpha channels, respectively.

    0 讨论(0)
  • 2021-01-28 04:05

    It's legit:

    Colors can be defined in the Red-green-blue-alpha model (RGBa) in two ways:

    Hexadecimal notation #RRGGBBAA and #RGBA

    • "#", followed by eight hexadecimal characters (0-9, A-F), where the first two digits represent the red part, the second two the green part, the third two the blue part and the last two the transparency.
    • "#", followed by four hexadecimal characters (0-9, A-F), where the first digit represents the red part, the second the green part, the third one the blue part and the last one the transparency. The four-digit RGB notation (#RGBA) and the eight-digit form (#RRGGBBAA) are equal, for example, #f038 and #ff003388 represent the same color.

    It's supported by Chrome 52, Firefox 49, Opera 39, and Safari 9.1

    0 讨论(0)
提交回复
热议问题