필굿스토리

 

 

https://www.freecodecamp.org/learn/responsive-web-design/basic-css/use-rgb-values-to-color-elements

 

 

Use RGB values to Color Elements

Another way you can represent colors in CSS is by using RGB values.

The RGB value for black looks like this:

rgb(0, 0, 0)

The RGB value for white looks like this:

rgb(255, 255, 255)

Instead of using six hexadecimal digits like you do with hex code, with RGB you specify the brightness of each color with a number between 0 and 255.

If you do the math, the two digits for one color equal 16 times 16, which gives us 256 total values. So RGB, which starts counting from zero, has the exact same number of possible values as hex code.

Here's an example of how you'd change the body background to orange using its RGB code.

body { background-color: rgb(255, 165, 0); }

 

 

TEST

Let's replace the hex code in our body element's background color with the RGB value for black: rgb(0, 0, 0)

 

 

<style>
  body {
    background-color: rgb(0,0,0);
  }
</style>

공유하기

facebook twitter kakaoTalk kakaostory naver band