CSS rgb()関数
例
さまざまな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 */
定義と使用法
rgb()関数は、赤-緑-青(RGB)モデルを使用して色を定義します。
RGBカラー値は、rgb(赤、緑、青)で指定されます。各パラメーターは、その色の強度を定義し、0〜255の整数、またはパーセンテージ値(0%〜100%)にすることができます。
たとえば、青のパラメータが最大値(255)に設定され、他のパラメータが0に設定されているため、rgb(0,0,255)の値は青としてレンダリングされます。
バージョン: | CSS2 |
---|
ブラウザのサポート
表の数字は、この機能を完全にサポートする最初のブラウザバージョンを示しています。
Function | |||||
---|---|---|---|---|---|
rgb() | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
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% |