We’ll cowl all of the out there strategies for specifying colours with CSS on this information.
There are six methods to declare CSS colours:
- Hexadecimal notation
- RGB
- RGBA
- HSL
- HSLA
- Colour key phrases
Hexadecimal
Instance
div
background-colour: #000000;
End result
Hexadecimal colour notation is a method of declaring a shade by indicating the quantity of pink, inexperienced and blue (RGB) it has.
This colour notation is predicated on the hexadecimal numeral system (base sixteen).
We’re extra accustomed to the decimal numeral system (base 10), so hex is a bit tough to know at first.
Within the instance above, black was declared as #000000, which suggests it has no purple, inexperienced or blue. (Colour principle tells us that the absence of any colour is black.)
In CSS hex colour notation:
- The quantity of purple is specified by the first two characters
- The quantity of inexperienced is specified by the second two characters
- The quantity of blue is specified by the final two characters
A legitimate CSS hex shade begins with a hash (#) adopted by both six characters or three characters. Characters could be between zero-9 and A-F (or lowercase a-f).
The minimal worth of every colour channel is 00, which is the same as zero in the decimal numeral system.
The most worth of every shade channel is FF, which is the same as 255 in the decimal numeral system.
So, understanding all of that, if we specify black, then:
| Pink | Inexperienced | Blue | Hex shade notation |
|---|---|---|---|
| 00 (zero in decimal) | 00 (zero in decimal) | 00 (zero in decimal) | #000000 |
What if we needed blue?
We will set the quantity of blue to the utmost worth (i.e. FF):
| Purple | Inexperienced | Blue | Hex shade notation |
|---|---|---|---|
| 00 (zero in decimal) | 00 (zero in decimal) | FF (255 in decimal) | #0000FF |
End result
We will specify an enormous quantity of colours just by adjusting the quantity of purple, inexperienced and blue within the colour.
As an example we needed get …read more
The post Introduction to CSS Colours appeared first on DICKLEUNG DESIGN 2014.

沒有留言:
張貼留言