CSS μμ± 04. border
βοΈ ν΄λΉ κΈμ ν¨μ€νΈμΊ νΌμ€ - νλ‘ νΈμλ κ°λ° κ°μμμ HTML & CSS, SASS(SCSS) Partμ λ°μμ κ°μ¬λμ κ°μμλ£λ₯Ό μ 리ν κ²μ λλ€.
border
#
μμμ βν λ리 μ βμ μ§μ - λ¨μΆ μμ± (λκ», μ’ λ₯, μμ)
#
μμ± κ°κ° | μλ―Έ | κΈ°λ³Έκ° |
---|---|---|
border-width | μ μ λκ»(λλΉ) | medium |
border-style | μ μ μ’ λ₯ | none |
border-color | μ μ μμ | black |
#
μ¬μ©λ²border
μ μμ± κ°λ€μ μλ΅ κ°λ₯νλ©° μμμλ μκ΄μ΄ μλ€. (νμ§λ§ κΈ°λ³Έμ μΌλ‘ border-style: none;
μ΄κΈ° λλ¬Έμ μ’
λ₯λ μ ν΄μ£Όμ΄μΌ λμΌλ‘ νμΈ κ°λ₯νλ€)
border: λκ» μ’
λ₯ μμ;border: λκ» μμ μ’
λ₯;border: μ’
λ₯ λκ» μμ;border: μ’
λ₯ μμ λκ»;border: μμ λκ» μ’
λ₯;border: μμ μ’
λ₯ λκ»;border: μμ μ’
λ₯;border: λκ» μ’
λ₯;...
.box {border: 1px solid red;}
border-top, right, bottom, left
#
μμμ ν΄λΉνλ μμΉμ βν λ리 μ βμ μ§μ - λ¨μΆ μμ± (λκ», μ’ λ₯, μμ)
#
μμ± κ°κ° | μλ―Έ | κΈ°λ³Έκ° |
---|---|---|
border-top-width | μ μ λκ»(λλΉ) | medium |
border-top-style | μ μ μ’ λ₯ | none |
border-top-color | μ μ μμ | black |
β¦ |
#
μ¬μ©λ²border-top, right, bottom, left
μ μμ± κ°λ€μ border
μ λ§μ°¬κ°μ§λ‘ μλ΅ κ°λ₯νλ©° μμμλ μκ΄μ΄ μλ€.
border-top: λκ» μ’
λ₯ μμ;border-top: λκ» μμ μ’
λ₯;border-top: μ’
λ₯ λκ» μμ;border-top: μ’
λ₯ μμ λκ»;border-top: μμ λκ» μ’
λ₯;border-top: μμ μ’
λ₯ λκ»;border-top: μμ μ’
λ₯;border-top: λκ» μ’
λ₯;...
.box {border-top: 1px solid red;}
border-width
#
μ μ λκ»(λλΉ)λ₯Ό μ§μ - λ¨μΆ (μ μ€λ₯Έμͺ½ μλ μΌμͺ½), κ°λ³ μμ±
#
μμ± κ°κ° | μλ―Έ | κΈ°λ³Έκ° |
---|---|---|
medium | μ€κ° λκ» | medium |
thin | μμ λκ» | |
thick | λκΊΌμ΄ λκ» | |
λ¨μ | px , em , cm λ± λ¨μλ‘ μ§μ |
#
μ¬μ©λ²border-width: μ μ° μλ μ’; /* μκ³ λ°©ν₯ */border-width: μ [μ’, μ°] μλ; /* μ μλ λ°©ν₯ */border-width: [μ, μλ] [μ’, μ°]; /* μ,μλ + μ’,μ° */border-width: [μ, μλ, μ’, μ°]; /* λͺ¨λ λ°©ν₯ */
.box {border-width: 10px 20px 30px 40px;border-width: 10px 20px 40px;border-width: 10px 40px;border-width: 10px;}
.box1 {border-width: 10px 20px 30px 40px; /* λ¨μΆ μμ± */}.box2 {/* κ°λ³ μμ± */border-top-width: 10px;border-right-width: 20px;border-bottom-width: 10px;border-left-width: 10px;}
border-style
#
μ μ μ’ λ₯λ₯Ό μ§μ - λ¨μΆ (μ μ€λ₯Έμͺ½ μλ μΌμͺ½), κ°λ³ μμ±
#
μμ± κ°κ° | μλ―Έ | κΈ°λ³Έκ° |
---|---|---|
none | μ μμ | none |
hidden | μ μμκ³Ό λμΌ( table μμμμ μ¬μ© ) | |
solid | μ€μ (μΌλ°μ ) | |
dotted | μ μ | |
dashed | νμ | |
double | λ μ€μ | |
groove | νμ΄ νμ¬μλ λͺ¨μ(μ ) | |
ridge | μμ λͺ¨μ(μ , groove μ λ°λ) | |
inset | μμ μ μ²΄κ° λ€μ΄κ° λͺ¨μ(μ ) | |
outset | μμ μ μ²΄κ° λμ¨ λͺ¨μ(μ ) |
#
μ¬μ©λ²border-style: μ μ° μλ μ’; /* μκ³ λ°©ν₯ */border-style: μ [μ’, μ°] μλ; /* μ μλ λ°©ν₯ */border-style: [μ, μλ] [μ’, μ°]; /* μ,μλ + μ’,μ° */border-style: [μ, μλ, μ’, μ°]; /* λͺ¨λ λ°©ν₯ */
.box {border-style: solid dotted double inset;border-style: solid dotted inset;border-style: solid inset;border-style: solid;}
.box1 {border-style: solid dotted double inset; /* λ¨μΆ μμ± */}.box2 {/* κ°λ³ μμ± */border-top-style: solid;border-right-style: dotted;border-bottom-style: double;border-left-style: inset;}
border-color
#
μ μ μμμ μ§μ - λ¨μΆ (μ μ€λ₯Έμͺ½ μλ μΌμͺ½), κ°λ³ μμ±
#
μμ± κ°κ° | μλ―Έ | κΈ°λ³Έκ° |
---|---|---|
μμ | μ μ μμμ μ§μ | black |
transparent | ν¬λͺ ν μ (μμμ λ°°κ²½μμ΄ λ³΄μ) |
#
μ¬μ©λ²border-color: μ μ° μλ μ’; /* μκ³ λ°©ν₯ */border-color: μ [μ’, μ°] μλ; /* μ μλ λ°©ν₯ */border-color: [μ, μλ] [μ’, μ°]; /* μ,μλ + μ’,μ° */border-color: [μ, μλ, μ’, μ°]; /* λͺ¨λ λ°©ν₯ */
.box {border-color: red green blue yellow;border-color: red green blue ;border-color: red green;border-color: red;}
.box1 {border-color: red green blue yellow; /* λ¨μΆ μμ± */}.box2 {/* κ°λ³ μμ± */border-top-color: red;border-right-color: green;border-bottom-color: blue;border-left-color: yellow;}
#
ν¬κΈ° μ¦κ°padding
κ³Ό λ§μ°¬κ°μ§λ‘ border
μ κ°λ§νΌ μμμ ν¬κΈ°κ° 컀μ§λ νμ
<div>Hello world!</div>
div {width: 100px;height: 100px;background: tomato;border: 20px;}
width
μ height
λ₯Ό 100px
λ‘ μ§μ νμμΌλ, border
κ°μ΄ 20px
λ‘ μ€μ λμ΄μ΄ 140px
μ μ μ¬κ°νμ΄ λνλκ² λμλ€.
#
μ§μ κ³μ°/* 100 x 100 (px) ν¬κΈ°μ μμ λ§λ€κΈ° */.box {width: 60px; /* +40px */height: 80px; /* +20px */background: tomato;border: 10px 20px;}
100 x 100 (px) ν¬κΈ°μ μμλ₯Ό λ§λ€κΈ° μν΄ μ§μ κ³μ°νλ€.
#
μλ κ³μ°/* 100 x 100 (px) ν¬κΈ°μ μμ λ§λ€κΈ° */.box {width: 100px;height: 100px;background: tomato;border: 10px 20px;box-sizing: border-box;}
box-sizing: border-box;
λ 100 x 100 ν¬κΈ°μ μμλ₯Ό λ§λ€κ³ κ·Έ μμμ border
μ΄ λ€μ΄κ°λλ‘ μλ κ³μ°ν΄μ€λ€.
#
Referenceν¨μ€νΈμΊ νΌμ€ - νλ‘ νΈμλ κ°λ° κ°μ - HTML & CSS, SASS(SCSS) Part by ParkYoungWoong