Funzione CSS RGB()
❮ Riferimento alle funzioni CSS
Esempio
Definisci diversi colori RGB:
#p1 {background-color:rgb(255,0,0);} /* red */
#p2 {background-color:rgb(0,255,0);} /* green */
#p3 {background-color:rgb(0,0,255);} /* blue */
Definizione e utilizzo
La funzione rgb() definisce i colori utilizzando il modello Rosso-verde-blu (RGB).
Un valore di colore RGB è specificato con: rgb(rosso, verde, blu). Ogni parametro definisce l'intensità di quel colore e può essere un numero intero compreso tra 0 e 255 o un valore percentuale (da 0% a 100%).
Ad esempio, il valore rgb(0,0,255) viene visualizzato come blu, perché il parametro blue è impostato sul valore più alto (255) e gli altri sono impostati su 0.
Versione: | CSS2 |
---|
Supporto browser
I numeri nella tabella specificano la prima versione del browser che supporta completamente la funzione.
Function | |||||
---|---|---|---|---|---|
rgb() | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Sintassi CSS
rgb(red, green, blue)
Value | Description |
---|---|
red | Defines the intensity of red as an integer between 0 and 255, or as a percentage value between 0% and 100% |
green | Defines the intensity of green as an integer between 0 and 255, or as a percentage value between 0% and 100% |
blue | Defines the intensity of blue as an integer between 0 and 255, or as a percentage value between 0% and 100% |
❮ Riferimento alle funzioni CSS