็ก์
Box Model์ border ์์ฑ ๋ณธ๋ฌธ

๐ ๋ฐ์ค ๋ชจ๋ธ ๋ฐฉํฅ ๐โ
โฉ๏ธ(์๊ณ ๋ฐฉํฅ์ผ๋ก)โฉ๏ธ
12์ - top
09์ - left 03์ - right
06์ - bottom

๐โborder-radius ๋ฐฉํฅ ๐โ
โฉ๏ธ(์๊ณ ๋ฐฉํฅ์ผ๋ก)โฉ๏ธ
10์ 30๋ถ 01์ 30๋ถ
07์ 30๋ถ 04์ 30๋ถ
๐ขโ โborder
padding ๋ฐ๊นฅ, margin ์์ชฝ์ ์๋ ํ ๋๋ฆฌ(๊ฒฝ๊ณ์ )์ ์ค์ ํ๋ ์์ฑ.
๐ฆโ Box Model ๊ตฌ์กฐ
(์ → ๋ฐ ์์)
[ content (๋ด์ฉ) ]
[ padding (์์ชฝ ์ฌ๋ฐฑ) ]
[ border (ํ
๋๋ฆฌ) ]
[ margin (๋ฐ๊นฅ ์ฌ๋ฐฑ) ]
๐ฏ ์ฃผ์ ์์ฑ 3๊ฐ์ง ๐ฏ
๐นโ border-width
ํ ๋๋ฆฌ์ ๋๊ป๋ฅผ ์ง์ .
.box { border-width: 2px; }
- px, em ๋ฑ์ ๋จ์.
- thin, medium, thick ํค์๋ ์ฌ์ฉ.
๐นโ border-style
ํ ๋๋ฆฌ์ ๋ชจ์์ ๊ฒฐ์ .
.box { border-style: 1px solid #fff; }
- ํ์ ์์ฑ์ผ๋ก ์์ผ๋ฉด ํ
๋๋ฆฌ๊ฐ ์ ๋ณด์ธ๋ค.
- solid: ์ค์ .
- dashed: ์ ์ .
- dotted: ์ .
- double: ์ด์ค์ .
- none: ์์.
๐นโ border-color
ํ ๋๋ฆฌ์ ์์์ ์ง์ .
.box { border-color: red; }
๐ ๊ฐ๋ณ ์์ฑโ
ํน์ ๋ฐฉํฅ์๋ง ํ ๋๋ฆฌ ์ ์ฉ ์์ฑ.
.box { border: 1px solid black; } /* ๊ธฐ๋ณธ ๊ตฌ์กฐ - 4๋ฐฉํฅ ๋ชจ๋ ์ ์ฉ */
.box { border-top-width: 3px; } /* ๋๊ป๋ง ๋ฐ๋ก */
.box { border-left-style: dashed; } /* ์คํ์ผ๋ง ๋ฐ๋ก */
- border-top: ์์ชฝ.
- border-right: ์ค๋ฅธ์ชฝ.
- border-bottom: ์๋.
- border-left: ์ผ์ชฝ.
๐จ ์ถ์ฝํ ์์ฑ (Shorthand)
ํ ๋๋ฆฌ๋ฅผ ํ ์ค๋ก ์ ์ํ๋ ์์ฑ.
/* ๊ธฐ๋ณธ ๊ตฌ์กฐ - 4๋ฐฉํฅ ๋ชจ๋ ์ ์ฉ */
.box { border: 1px solid black; }
/* ๋ฐฉํฅ๋ณ ์ถ์ฝํ */
.box { border-top: 2px solid red; }
.box { border-right: 2px solid blue; }
.box { border-bottom: 2px solid green; }
.box { border-left: 2px solid black; }
- ๋ฌธ๋ฒ: border: border-width(๋๊ป) border-style(์คํ์ผ) border-color(์์);
๐นโ border-radius
๋ชจ์๋ฆฌ๋ฅผ ๋ฅ๊ธ๊ฒ(๊ณก๋ฅ ) ๋ง๋๋ ์์ฑ.
.box { border-radius: 10px; } /* ๋ชจ๋ ๋ชจ์๋ฆฌ 10px ๋ฅ๊ธ๊ฒ */
- ๊ฐ๋ณ ์์ฑ
๊ฐ ๋ชจ์๋ฆฌ๋ง๋ค ๋ค๋ฅธ ๊ฐ์ ์ค ์ ์๋ค.
.box { border-top-left-radius: 10px; }
.box { border-top-right-radius: 20px; }
.box { border-bottom-right-radius: 30px; }
.box { border-bottom-left-radius: 40px; }
- ์ ๋ง๋ค๊ธฐ
์ ์ฌ๊ฐํ์ 50% ์ฃผ๋ฉด ์์ ํ ์์ด ๋๋ค.
.box { border-radius: 50%; }
- ๋ชจ์๋ฆฌ๋ณ ์ค์
/* 4๊ฐ */
.box { border-radius: 10px 20px 30px 40px; }
/* 2๊ฐ */
.box { border-radius: 10px 20px; } /* (์ผ์+์ค์), (์ค์+์ผ์) */
/* 3๊ฐ */
.box { border-radius: 10px 20px 30px; } /* (์ผ์), (์ค์+์ผ์), (์ค์) */
๐ ์์:
- ์ผ์ชฝ ์ (top-left)
- ์ค๋ฅธ์ชฝ ์ (top-right)
- ์ค๋ฅธ์ชฝ ์๋ (bottom-right)
- ์ผ์ชฝ ์๋ (bottom-left)
๐โ POINT ๐โ
โ๏ธ ํ ๋๋ฆฌ๊ฐ ํ๋ฉด์ ๋ํ๋์ง ์๋๋ค๋ฉด border-style ์ ๋นผ๋จน์ง ์์๋์ง ์ฒดํฌํ๊ธฐ. โ๏ธ
โ๏ธ border: none; ์ ๋ฒํผ์ด๋ ์ ๋ ฅ์ฐฝ์ ๊ธฐ๋ณธ ํ ๋๋ฆฌ๋ฅผ ์ ๊ฑฐํ ๋ ์ฌ์ฉํ๋ค. โ๏ธ
โ๏ธ ๋ณด๋ ์ญ์ padding ์ฒ๋ผ ์์์ ์ ์ฒด ํฌ๊ธฐ์ ์ํฅ์ ์ฃผ๋ฏ๋ก, ๋ ์ด์์์ด ํ์ด์ง๋ ๊ฒ์ ๋ง์ผ๋ ค๋ฉด box-sizing: border-box; ๋ฅผ ํจ๊ป ์ฌ์ฉํ๋ ๊ฒ์ด ์ข๋ค. โ๏ธ
๐ ๋ณด๋ ์ฃผ์ ์์ฑ ์์ฝํ ๐
| ์์ฑ | ์ค๋ช | ์ฃผ์ ๊ฐ ์์ |
| border-style | ํ ๋๋ฆฌ ๋ชจ์ (ํ์) | solid, dashed, none |
| border-width | ํ ๋๋ฆฌ ๋๊ป | 1px, 0.5rem |
| border-color | ํ ๋๋ฆฌ ์์ | #000, transparent |
| border-radius | ๋ชจ์๋ฆฌ ๊ณก๋ฅ | 8px, 50% |
| outline | ํ ๋๋ฆฌ ๋ฐ๊นฅ์ ์ธ๊ณฝ์ | ๋ณด๋์ ๋ฌ๋ฆฌ ๊ณต๊ฐ์ ์ฐจ์งํ์ง ์์ |
'<style>' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| Box Model์ padding ์์ฑ (0) | 2026.03.18 |
|---|---|
| Box Model์ margins ์์ฑ (0) | 2026.03.18 |
| CSS์ Box Model (0) | 2026.03.18 |
| display: inline-block ์์ฑ (0) | 2026.03.18 |
| table ์์ฑ (0) | 2026.03.18 |