How does hexadecimal color work?

后端 未结 7 1730
刺人心
刺人心 2020-12-05 10:24

What does the hexadecimal that represents a CSS color mean? How can I tell what color it is without memorizing the exact code? Does it have any relationships with RGB (and C

7条回答
  •  爱一瞬间的悲伤
    2020-12-05 10:54

    Hexadecimal uses sixteen distinct symbols, in the case of css color the symbols 0–9 to represent values zero to nine (obviously), and A, B, C, D, E, F to represent values ten to fifteen. So, using one Hexadecimal character you can represent 16 values. With two Hexadecimal you can represent 256 (16*16) values.

    In RGB you have colours represented by Red Green Blue (R=0-255, G=0-255, B=0-255), so we use 3 pairs of Hexadecimal symbols! So when you see an RGB color, you can make the calculation below.

    Example:

    Hex: #4C8ED5 is RGB: 76, 142, 213.

    Because 4C = 76(Red), 8E = 142(Green), D5 = 213(Blue)!

    Hope it helps your understanding!

    More to read: Hexadecimal on Wikipedia and a nice RGB to Hexidecimal Converter

提交回复
热议问题