λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
CSS

[CSS] CSS의 색상 ν‘œν˜„ 방법

by _토맀토 2022. 8. 24.
728x90

CSS : 색상 ν‘œν˜„ 방법

CSSμ—μ„œλŠ” 색상을 μ„€μ •ν•˜λŠ” 총 7κ°€μ§€μ˜ 방법이 μžˆμŠ΅λ‹ˆλ‹€. λ¨Όμ € κΈ°μ‘΄ CSS에 있던 방법 3가지, CSS3μ—μ„œ μΆ”κ°€λœ 4가지 방법이 μžˆμŠ΅λ‹ˆλ‹€.
이번 μ‹œκ°„μ—λŠ” μ΄λŸ¬ν•œ CSS의 색상 ν‘œν˜„ 방법에 λŒ€ν•΄ μ•Œμ•„λ³΄κ² μŠ΅λ‹ˆλ‹€!πŸ˜„


πŸ”Ά CSS 색상 ν‘œν˜„ 방법 πŸ”Ά

#1. 색상 μ΄λ¦„μœΌλ‘œ ν‘œν˜„

red, pink와 같이 μƒ‰μƒμ˜ 이름을 λ‚˜νƒ€λ‚΄λŠ” λ°©λ²•μœΌλ‘œ, μ•½ 140κ°€μ§€μ˜ 색상 이름듀이 λΈŒλΌμš°μ €μ— 미리 μ •μ˜λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

p {background-color: orange;}

orange


#2. RGBκ°’μœΌλ‘œ ν‘œν˜„

rgb(red, green, blue)와 같은 ν˜•μ‹μœΌλ‘œ 색을 ν‘œν˜„ν•©λ‹ˆλ‹€.
μ—¬κΈ°μ„œ red, green, blue 각각의 λ³€μˆ˜μ—λŠ” 0μ—μ„œ 255μ‚¬μ΄μ˜ μ •μˆ˜λ₯Ό μž…λ ₯ν•˜κ±°λ‚˜ λ°±λΆ„μœ¨ 값을 μ§€μ •ν•˜μ—¬ 색상을 μ„€μ •ν•©λ‹ˆλ‹€.

p {background-color: rgb(255, 165, 0);}
p {background-color: rgb(100%, 0%, 0%);}

orange

red


#3. HEX(16μ§„μˆ˜)κ°’μœΌλ‘œ ν‘œν˜„

hex(16μ§„μˆ˜) 색상값은 RGB 색상값을 각각 16μ§„μˆ˜λ‘œ λ³€ν™˜ν•œ κ²ƒμž…λ‹ˆλ‹€.
#rrggbb = rr: red / gg: green / bb : blue둜 00μ—μ„œ ffκΉŒμ§€μ˜ λ²”μœ„ κ°’μž…λ‹ˆλ‹€.

p {background-color: #FFA500;}

orange

✏️ HEX ν‘œ ν™•μΈν•˜κΈ°
이름 색상
μ½”λ“œ
이름 색상
μ½”λ“œ
이름 색상
μ½”λ“œ
red #FF0000 lime #00FF00 blue #0000FF
indianred #CD5C5C aquamarine #7FFFD4 cyan(=aqua) #00FFFF
darksalmon #E9967A mediumspringgreen #00FA9A aqua(=cyan) #00FFFF
lightcoral #F08080 springgreen #00FF7F mediumturquoise #48D1CC
salmon #FA8072 palegreen #98FB98 darkturquoise #00CED1
orangered #FF4500 greenyellow #ADFF2F cadetblue #5F9EA0
crimson #DC143C chartreuse #7FFF00 slategray #708090
firebrick #B22222 lawngreen #7CFC00 lightcyan #E0FFFF
darkred #8B0000 green #008000 paleturquoise #AFEEEE
mediumvioletred #C71585 lightgreen #90EE90 powderblue #B0E0E6
pink #FFC0CB yellowgreen #9ACD32 lightsteelblue #B0C4DE
lightpink #FFB6C1 limegreen #32CD32 steelblue #4682B4
hotpink #FF69B4 mediumseagreen #3CB371 lightblue #ADD8E6
deeppink #FF1493 darkseagreen #8FBC8F skyblue #87CEEB
paleviolentred #DB7093 forestgreen #228B22 lightskyblue #87CEFA
darkkhaki #BDB76B seagreen #2E8B57 deepskyblue #00BFFF
khaki #F0E68C olivedrab #6B8E23 cornflowerblue #6495ED
palegoldenrod #EEE8AA olive #808000 royalblue #4169E1
lightgoldenrodyellow #FAFAD2 darkolivegreen #556B2F mediumslateblue #7B68EE
lightyellow #FFFFE0 darkgreen #006400 dodgerblue #1E90FF
lemonchiffon #FFFACD mediumaquamarine #66CDAA mediumblue #0000CD
yellow #FFFF00 turquoise #40E0D0 darkblue #00008B
gold #FFD700 lightseagreen #20B2AA navy #000080
papayawhip #FFEFD5 darkcyan #008B8B midnightblue #191970
moccasin #FFE4B5 teal #008080 gainsboro #DCDCDC
peachpuff #FFDAB9 honeydew #F0FFF0 lightgrey #D3D3D3
lightsalmon #FFA07A mintcream #F5FFFA silver #C0C0C0
orange #FFA500 azure #F0FFFF darkgray #A9A9A9
darkorange #FF8C00 aliceblue #F0F8FF gray(grey) #808080
coral #FF7F50 ghostwhite #F8F8FF dimgray #696969
tomato #FF6347 whitesmoke #F5F5F5 darkslategray #2F4F4F
orangered #FF4500 lavenderblush #FFF0F5 lightslategray #778899
lavender #E6E6FA mistyrose #FFE4E1 peru #CD853F
thistle #D8BFD8 antiquewhite #FAEBD7 chocolate #D2691E
plum #DDA0DD seashell #FFF5EE maroon #800000
violet #EE82EE snow #FFFAFA saddlebrown #8B4513
fuchsia(=magenta) #FF00FF beige #F5F5DC brown #A52A2A
magenta(=fuchsia) #FF00FF linen #FAF0E6 sienna #A0522D
orchid #DA70D6 oldlace #FDF5E6 darkred #8B0000
cornsilk #FFF8DC floralwhite #FFFAF0 burlywood #DEB887
blanchedalmond #FFEBCD ivory #FFFFF0 tan #D2B48C
bisque #FFE4E4 mediumorchid #BA55D3 rosybrown #BC8F8F
navajowhite #FFDEAD darkorchid #9932CC mediumpurple #9370DB
blueviolet #8A2BE2 darkviolet #9400D3 darkmagenta #8B008B
slateblue #6A5ACD purple #800080 wheat #F5DEB3
darkslateblue #483D8B indigo #4B0082 darkgoldenrod #B8860B
sandybrown #F4A460 goldenrod #DAA520
black #000000 white #FFFFFF

πŸ”Ά CSS3μ—μ„œ μΆ”κ°€λœ 색상 ν‘œν˜„ 방법 πŸ”Ά

#1. RGBA μƒ‰μƒκ°’μœΌλ‘œ ν‘œν˜„

RGBA 색상값은 RGB 색상값에 μ•ŒνŒŒ 채널 값을 λ”ν•œ μƒ‰μƒκ°’μž…λ‹ˆλ‹€.
μ—¬κΈ°μ„œ μ•ŒνŒŒ 채널(alpha channel)μ΄λž€ μƒ‰μƒμ˜ 투λͺ…도λ₯Ό λ‚˜νƒ€λ‚΄λŠ” μ±„λ„μž…λ‹ˆλ‹€. μ•ŒνŒŒ 채널 값은 μ™„μ „ν•œ 투λͺ… μƒνƒœμΈ 0.0λΆ€ν„° 투λͺ…도가 μ „ν˜€ μ—†λŠ” 1.0 μ‚¬μ΄μ˜ 값을 κ°€μ§‘λ‹ˆλ‹€.

p {background-color: rgba(255, 165, 0, 0);}
p {background-color: rgba(255, 165, 0, 0.5);}
p {background-color: rgba(255, 165, 0, 1);}

orange

orange

orange


#2. HSL μƒ‰μƒκ°’μœΌλ‘œ ν‘œν˜„

HSL 색상값은 λΉ›μ˜ μ‚Όμ›μƒ‰μœΌλ‘œ 색을 ν‘œν˜„ν•˜λŠ” RGB μƒ‰μƒκ°’κ³ΌλŠ” 달리 색상, 채도, λͺ…도λ₯Ό μ‚¬μš©ν•΄μ„œ 색을 ν‘œν˜„ν•©λ‹ˆλ‹€.
즉 HSL은 각각 색상(Hue), 채도(Saturation), λͺ…도(Lightness)λ₯Ό μ˜λ―Έν•©λ‹ˆλ‹€.
색상은 0λΆ€ν„° 360 μ‚¬μ΄μ˜ 값에 따라 κ²°μ •λ˜λ©°, μƒ‰μƒν™˜(color wheel)의 각도λ₯Ό λ‚˜νƒ€λƒ…λ‹ˆλ‹€.

p {background-color: hsl(39, 100%, 50%);}

orange


#3. HSLAκ°’μœΌλ‘œ ν‘œν˜„

rgba와 λ§ˆμ°¬κ°€μ§€λ‘œ hsl에 뢈투λͺ…도λ₯Ό μΆ”κ°€ν•œ 색상 ν‘œν˜„ λ°©λ²•μž…λ‹ˆλ‹€.

p {background-color: hsl(39, 100%, 50%, 0);}
p {background-color: hsl(39, 100%, 50%, 0.5);}
p {background-color: hsl(39, 100%, 50%, 1);}

orange

orange

orange


728x90

λŒ“κΈ€


Lucky Charms Rainbow
js
html
css