Ver3.0 ๐จ ์ ์ฐํ ๋ ์ด์์ ๊ตฌํ: CSS ๊ทธ๋ฆฌ๋์ ํ๋ ์ค๋ฐ์ค ํ์ฉ๋ฒ

๐จ ์ ์ฐํ ๋ ์ด์์ ๊ตฌํ: CSS ๊ทธ๋ฆฌ๋์ ํ๋ ์ค๋ฐ์ค ํ์ฉ๋ฒ
์น ๊ฐ๋ฐ์๋ผ๋ฉด ๋ฐ๋์ ์์์ผ ํ ๋ ์ด์์์ ๋ชจ๋ ๊ฒ! ๐
๐ ์ ์ง๊ธ CSS ๊ทธ๋ฆฌ๋์ ํ๋ ์ค๋ฐ์ค๋ฅผ ๋ฐฐ์์ผ ํ ๊น?
์๋
! ์ค๋์ ์น ๊ฐ๋ฐ์์ ์ ๋ง ์ค์ํ ์ฃผ์ ๋ฅผ ๋ค๋ค๋ณผ ๊ฑฐ์ผ. ๋ฐ๋ก CSS ๊ทธ๋ฆฌ๋(Grid)์ ํ๋ ์ค๋ฐ์ค(Flexbox)! ๐
์์งํ ๋งํด์, ์์ ์๋ ์น ๋ ์ด์์ ๋ง๋๋ ๊ฒ ์ ๋ง ๊ณจ์น ์ํ ์ด. float๋ก ์ด๊ฒ์ ๊ฒ ๋์ฐ๊ณ , clear๋ก ์ ๋ฆฌํ๊ณ ... ์๊ฐ๋ง ํด๋ ๋จธ๋ฆฌ๊ฐ ์ํ์ง? ๐
ํ์ง๋ง ์ด์ ๋ ๋ฌ๋ผ! CSS ๊ทธ๋ฆฌ๋์ ํ๋ ์ค๋ฐ์ค ๋๋ถ์ ๋ ์ด์์ ์์
์ด ์ ๋ง ์ฌ์์ก์ด. ๋ง์น ๋ ๊ณ ๋ธ๋ก ์กฐ๋ฆฝํ๋ฏ์ด ์ง๊ด์ ์ผ๋ก ๋ฐฐ์นํ ์ ์๊ฒ ๋๊ฑฐ๋ .
ํนํ ์์ฆ์ฒ๋ผ ๋ชจ๋ฐ์ผ, ํ๋ธ๋ฆฟ, ๋ฐ์คํฌํฑ ๋ฑ ๋ค์ํ ํ๋ฉด ํฌ๊ธฐ์ ๋์ํด์ผ ํ๋ ์๋์๋ ์ด ๋ ๊ธฐ์ ์ด ํ์์ผ. ๋ฐ์ํ ์น ๋์์ธ์ ๊ตฌํํ๋ ๋ฐ ์ด๋งํ ๋๊ตฌ๊ฐ ์๊ฑฐ๋ ! ๐ช
๐ฏ ํ๋ ์ค๋ฐ์ค(Flexbox) ์์ ์ ๋ณต
์, ์ด์ ๋ณธ๊ฒฉ์ ์ผ๋ก ํ๋ ์ค๋ฐ์ค๋ถํฐ ํํค์ณ๋ณผ๊น? ํ๋ ์ค๋ฐ์ค๋ 2009๋
์ ์ฒ์ ์ ์๋๊ณ , ์ง๊ธ์ ๋ชจ๋ ์ฃผ์ ๋ธ๋ผ์ฐ์ ์์ ์๋ฒฝํ๊ฒ ์ง์ํ๊ณ ์์ด. ๐
ํ๋ ์ค๋ฐ์ค์ ํต์ฌ ๊ฐ๋
์ "์ ์ฐํ ๋ฐ์ค"์ผ. ์ปจํ
์ด๋ ์์ ์์ดํ
๋ค์ด ๊ณต๊ฐ์ ๋ฐ๋ผ ์๋์ผ๋ก ํฌ๊ธฐ๋ฅผ ์กฐ์ ํ๊ณ ๋ฐฐ์น๋๋ ๊ฑฐ์ง. ๋ง์น ๋ฌผ์ฒ๋ผ ํ๋ฅด๋ฏ์ด ๋ง์ด์ผ! ๐ง
๐ฆ ํ๋ ์ค๋ฐ์ค์ ๊ธฐ๋ณธ ๊ตฌ์กฐ
ํ๋ ์ค๋ฐ์ค๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด ๋จผ์ ๋ ๊ฐ์ง ๊ฐ๋
์ ์ดํดํด์ผ ํด:
1. ํ๋ ์ค ์ปจํ
์ด๋(Flex Container) - ๋ถ๋ชจ ์์
2. ํ๋ ์ค ์์ดํ
(Flex Items) - ์์ ์์๋ค
์ปจํ
์ด๋์ display: flex๋ฅผ ์ ์ธํ๋ ์๊ฐ, ๊ทธ ์์ ์์ ์์๋ค์ ์๋์ผ๋ก ํ๋ ์ค ์์ดํ
์ด ๋ผ. ์ ๋ง ๊ฐ๋จํ์ง? ๐
/* ๋ถ๋ชจ ์์์ ์ ์ฉ */
.container {
display: flex;
}
/* ์ด์ ์์ ์์๋ค์ด ๊ฐ๋ก๋ก ๋๋ํ ๋ฐฐ์น๋จ! */
๐จ ์ฃผ์ ๋ฐฉํฅ(Main Axis)๊ณผ ๊ต์ฐจ ์ถ(Cross Axis)
ํ๋ ์ค๋ฐ์ค๋ฅผ ์ ๋๋ก ์ดํดํ๋ ค๋ฉด ์ถ(axis) ๊ฐ๋
์ด ์ค์ํด. ๋ ๊ฐ์ ์ถ์ด ์๊ฑฐ๋ :
์ฃผ์ ์ถ(Main Axis) - ์์ดํ
๋ค์ด ๋ฐฐ์น๋๋ ์ฃผ๋ ๋ฐฉํฅ
๊ต์ฐจ ์ถ(Cross Axis) - ์ฃผ์ ์ถ์ ์์ง์ธ ๋ฐฉํฅ
๊ธฐ๋ณธ์ ์ผ๋ก ์ฃผ์ ์ถ์ ๊ฐ๋ก(โ)์ผ. ํ์ง๋ง flex-direction์ผ๋ก ๋ฐฉํฅ์ ๋ฐ๊ฟ ์ ์์ด!
โข row (๊ธฐ๋ณธ๊ฐ) - ์ผ์ชฝ์์ ์ค๋ฅธ์ชฝ์ผ๋ก โ
โข row-reverse - ์ค๋ฅธ์ชฝ์์ ์ผ์ชฝ์ผ๋ก โ
โข column - ์์์ ์๋๋ก โ
โข column-reverse - ์๋์์ ์๋ก โ
.container {
display: flex;
flex-direction: row; /* ๊ฐ๋ก ๋ฐฐ์น */
}
.container-vertical {
display: flex;
flex-direction: column; /* ์ธ๋ก ๋ฐฐ์น */
}
๐ฏ justify-content: ์ฃผ์ ์ถ ์ ๋ ฌ
justify-content๋ ์ฃผ์ ์ถ์ ๋ฐ๋ผ ์์ดํ ๋ค์ ์ด๋ป๊ฒ ๋ฐฐ์นํ ์ง ๊ฒฐ์ ํด. ์ด๊ฒ ์ง์ง ๊ฐ๋ ฅํ ๊ธฐ๋ฅ์ด์ผ! โก
(๊ธฐ๋ณธ๊ฐ)
(๋์ผ๋ก)
(๊ฐ์ด๋ฐ)
(์๋ ์ ๋ ฌ)
(๊ท ๋ฑ ๋ถ๋ฐฐ)
(์์ ๊ท ๋ฑ)
/* ์์ดํ
๋ค์ ๊ฐ์ด๋ฐ ์ ๋ ฌ */
.container {
display: flex;
justify-content: center;
}
/* ์์ดํ
๋ค ์ฌ์ด์ ๊ท ๋ฑํ ๊ฐ๊ฒฉ */
.container-spaced {
display: flex;
justify-content: space-between;
}
/* ๋ค๋น๊ฒ์ด์
๋ฉ๋ด ๋ง๋ค๊ธฐ */
.nav {
display: flex;
justify-content: space-around;
padding: 20px;
background: #667eea;
}
.nav-item {
color: white;
padding: 10px 20px;
}
โฌ๏ธ align-items: ๊ต์ฐจ ์ถ ์ ๋ ฌ
align-items๋ ๊ต์ฐจ ์ถ์ ๋ฐ๋ผ ์์ดํ ๋ค์ ์ ๋ ฌํด. ์ฃผ์ ์ถ์ด ๊ฐ๋ก๋ผ๋ฉด, ๊ต์ฐจ ์ถ์ ์ธ๋ก๊ฐ ๋๋ ๊ฑฐ์ง! ๐
โข stretch (๊ธฐ๋ณธ๊ฐ) - ์ปจํ ์ด๋ ๋์ด๋งํผ ๋์ด๋จ
โข flex-start - ๊ต์ฐจ ์ถ์ ์์์ ์ ๋ ฌ
โข flex-end - ๊ต์ฐจ ์ถ์ ๋์ ์ ๋ ฌ
โข center - ๊ต์ฐจ ์ถ์ ์ค์ ์ ๋ ฌ
โข baseline - ํ ์คํธ ๋ฒ ์ด์ค๋ผ์ธ ์ ๋ ฌ
/* ์ธ๋ก ์ค์ ์ ๋ ฌ (๊ฐ์ฅ ๋ง์ด ์ฐ๋ ํจํด!) */
.container {
display: flex;
justify-content: center; /* ๊ฐ๋ก ์ค์ */
align-items: center; /* ์ธ๋ก ์ค์ */
height: 100vh; /* ํ๋ฉด ์ ์ฒด ๋์ด */
}
/* ์ด์ ์๋ฒฝํ ์ค์ ์ ๋ ฌ! */
๐ flex-wrap: ์ค๋ฐ๊ฟ ์ฒ๋ฆฌ
๊ธฐ๋ณธ์ ์ผ๋ก ํ๋ ์ค ์์ดํ
๋ค์ ํ ์ค์ ๋ค ๋ค์ด๊ฐ๋ ค๊ณ ํด. ๊ณต๊ฐ์ด ๋ถ์กฑํ๋ฉด ์์ดํ
๋ค์ด ์ฐ๊ทธ๋ฌ์ง๋ ๊ฑฐ์ง. ๐
ํ์ง๋ง flex-wrap์ ์ฌ์ฉํ๋ฉด ์์ดํ
๋ค์ด ์๋์ผ๋ก ๋ค์ ์ค๋ก ๋์ด๊ฐ!
โข nowrap (๊ธฐ๋ณธ๊ฐ) - ํ ์ค์ ๋ชจ๋ ๋ฐฐ์น
โข wrap - ์ฌ๋ฌ ์ค๋ก ๋๋
โข wrap-reverse - ์ฌ๋ฌ ์ค๋ก ๋๋๋ ์ญ์
/* ๋ฐ์ํ ์นด๋ ๋ ์ด์์ */
.card-container {
display: flex;
flex-wrap: wrap;
gap: 20px; /* ์์ดํ
๊ฐ ๊ฐ๊ฒฉ */
}
.card {
flex: 1 1 300px; /* ์ต์ 300px, ์ ์ฐํ๊ฒ ๋์ด๋จ */
padding: 20px;
background: #f5f5f5;
border-radius: 10px;
}
๐ช flex ์์ฑ: ์์ดํ ์ ํฌ๊ธฐ ์กฐ์
์ด์ ๊ฐ๋ณ ์์ดํ
์ ์ ์ฉํ๋ ์์ฑ์ ๋ณผ ์ฐจ๋ก์ผ. flex๋ ์ธ ๊ฐ์ง ์์ฑ์ ๋จ์ถ ํํ์ด์ผ:
flex-grow - ๋์ด๋๋ ๋น์จ
flex-shrink - ์ค์ด๋๋ ๋น์จ
flex-basis - ๊ธฐ๋ณธ ํฌ๊ธฐ
๋ณดํต์ flex: 1 ์ด๋ฐ ์์ผ๋ก ๊ฐ๋จํ๊ฒ ์จ!
/* ๋ชจ๋ ์์ดํ
์ด ๋์ผํ ํฌ๊ธฐ๋ก */
.item {
flex: 1;
}
/* ํน์ ์์ดํ
๋ง 2๋ฐฐ ํฌ๊ธฐ๋ก */
.item-large {
flex: 2;
}
/* 3๊ฐ ์์ดํ
์ด 1:2:1 ๋น์จ๋ก */
.item-1 { flex: 1; }
.item-2 { flex: 2; }
.item-3 { flex: 1; }
/* ๊ณ ์ ํฌ๊ธฐ + ์ ์ฐํ ํฌ๊ธฐ ์กฐํฉ */
.sidebar {
flex: 0 0 250px; /* 250px ๊ณ ์ */
}
.main-content {
flex: 1; /* ๋๋จธ์ง ๊ณต๊ฐ ๋ชจ๋ ์ฐจ์ง */
}
๐ช ์ค์ ์์ : ๋ค๋น๊ฒ์ด์ ๋ฐ ๋ง๋ค๊ธฐ
์, ์ด์ ๋ฐฐ์ด ๊ฑธ ํ์ฉํด์ ์ค์ ๋ก ๋ง์ด ์ฐ๋ ๋ค๋น๊ฒ์ด์ ๋ฐ๋ฅผ ๋ง๋ค์ด๋ณผ๊น? ๐จ
<nav class="navbar">
<div class="logo">MyWebsite</div>
<div class="nav-links">
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Contact</a>
</div>
<div class="nav-button">
<button>Login</button>
</div>
</nav>
/* CSS */
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 40px;
background: #667eea;
color: white;
}
.logo {
font-size: 24px;
font-weight: bold;
}
.nav-links {
display: flex;
gap: 30px;
}
.nav-links a {
color: white;
text-decoration: none;
transition: opacity 0.3s;
}
.nav-links a:hover {
opacity: 0.7;
}
.nav-button button {
padding: 10px 25px;
background: white;
color: #667eea;
border: none;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
}
/* ๋ชจ๋ฐ์ผ ๋์ */
@media (max-width: 768px) {
.navbar {
flex-direction: column;
gap: 20px;
}
.nav-links {
flex-direction: column;
text-align: center;
gap: 15px;
}
}
โข ๋ฐ์ํ ๋์์ธ์ด ์ฝ๊ฒ ๊ตฌํ๋จ
โข ์์ดํ ๊ฐ ๊ฐ๊ฒฉ ์กฐ์ ์ด ์์ ๋ก์
โข ์ ์ง๋ณด์๊ฐ ํธํจ
โข ๋ธ๋ผ์ฐ์ ํธํ์ฑ ์๋ฒฝ
๐จ CSS ๊ทธ๋ฆฌ๋(Grid) ๋ง์คํฐํ๊ธฐ
์, ์ด์ CSS ๊ทธ๋ฆฌ๋๋ก ๋์ด๊ฐ๋ณผ๊น! ๊ทธ๋ฆฌ๋๋ ํ๋ ์ค๋ฐ์ค๋ณด๋ค ์กฐ๊ธ ๋ฆ๊ฒ ๋์์ง๋ง, ๋ ๊ฐ๋ ฅํ ๊ธฐ๋ฅ์ ๊ฐ์ง๊ณ ์์ด. ๐
ํ๋ ์ค๋ฐ์ค๊ฐ 1์ฐจ์(ํ ๋๋ ์ด)์ด๋ผ๋ฉด, ๊ทธ๋ฆฌ๋๋ 2์ฐจ์(ํ๊ณผ ์ด์ ๋์์) ๋ค๋ฃฐ ์ ์์ด. ๋ง์น ์์
์คํ๋ ๋์ํธ์ฒ๋ผ ๋ง์ด์ผ! ๐
๋ณต์กํ ๋ ์ด์์์ ๋ง๋ค ๋๋ ๊ทธ๋ฆฌ๋๊ฐ ํจ์ฌ ํธํด. ํนํ ๊ฐค๋ฌ๋ฆฌ, ๋์๋ณด๋, ๋งค๊ฑฐ์ง ์คํ์ผ ๋ ์ด์์์๋ ๊ทธ๋ฆฌ๋๊ฐ ์ต๊ณ ์ผ!
๐ ๊ทธ๋ฆฌ๋์ ๊ธฐ๋ณธ ๊ฐ๋
๊ทธ๋ฆฌ๋๋ฅผ ์ดํดํ๋ ค๋ฉด ๋ช ๊ฐ์ง ์ฉ์ด๋ฅผ ์์์ผ ํด:
๊ทธ๋ฆฌ๋ ์ปจํ
์ด๋(Grid Container) - ๋ถ๋ชจ ์์
๊ทธ๋ฆฌ๋ ์์ดํ
(Grid Items) - ์์ ์์๋ค
๊ทธ๋ฆฌ๋ ๋ผ์ธ(Grid Lines) - ๊ทธ๋ฆฌ๋๋ฅผ ๋๋๋ ์ ๋ค
๊ทธ๋ฆฌ๋ ํธ๋(Grid Tracks) - ํ(row) ๋๋ ์ด(column)
๊ทธ๋ฆฌ๋ ์
(Grid Cell) - ํ๋์ ์นธ
๊ทธ๋ฆฌ๋ ์์ญ(Grid Area) - ์ฌ๋ฌ ์
์ ํฉ์น ์์ญ
/* ๊ทธ๋ฆฌ๋ ์ปจํ
์ด๋ ์ ์ธ */
.container {
display: grid;
}
/* 3๊ฐ์ ์ด๋ก ๋๋๊ธฐ */
.container {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
/* ๋๋ ๊ฐ๋จํ๊ฒ */
grid-template-columns: repeat(3, 1fr);
}
/* ํ์ ๋์ด ์ง์ */
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: 200px 300px;
}
๐ช grid-template-columns์ grid-template-rows
์ด ๋ ์์ฑ์ด ๊ทธ๋ฆฌ๋์ ํต์ฌ์ด์ผ. ์ด๊ณผ ํ์ ํฌ๊ธฐ๋ฅผ ์ ์ํ๋ ๊ฑฐ์ง!
/* ๊ณ ์ ํฌ๊ธฐ */
.grid-fixed {
display: grid;
grid-template-columns: 200px 300px 200px;
}
/* ๋น์จ ํฌ๊ธฐ */
.grid-ratio {
display: grid;
grid-template-columns: 1fr 2fr 1fr;
}
/* ํผํฉ ์ฌ์ฉ */
.grid-mixed {
display: grid;
grid-template-columns: 250px 1fr 250px;
/* ์์ชฝ 250px ๊ณ ์ , ๊ฐ์ด๋ฐ๋ ์ ์ฐํ๊ฒ */
}
/* ์๋ ํฌ๊ธฐ */
.grid-auto {
display: grid;
grid-template-columns: auto 1fr auto;
/* ๋ด์ฉ๋ฌผ ํฌ๊ธฐ์ ๋ง์ถฐ ์๋ ์กฐ์ */
}
/* ์ต์/์ต๋ ํฌ๊ธฐ */
.grid-minmax {
display: grid;
grid-template-columns: repeat(3, minmax(200px, 1fr));
/* ์ต์ 200px, ์ต๋ 1fr */
}
๐ repeat() ํจ์ ํ์ฉ
๊ฐ์ ํจํด์ ๋ฐ๋ณตํ ๋๋ repeat() ํจ์๋ฅผ ์ฐ๋ฉด ์ฝ๋๊ฐ ํจ์ฌ ๊ฐ๊ฒฐํด์ ธ!
/* ๊ธฐ๋ณธ ์ฌ์ฉ */
.grid {
grid-template-columns: repeat(4, 1fr);
/* 1fr 1fr 1fr 1fr๊ณผ ๋์ผ */
}
/* ํจํด ๋ฐ๋ณต */
.grid-pattern {
grid-template-columns: repeat(3, 100px 200px);
/* 100px 200px 100px 200px 100px 200px */
}
/* auto-fill: ๊ฐ๋ฅํ ๋ง์ ์ด ์์ฑ */
.grid-auto-fill {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
/* ํ๋ฉด ํฌ๊ธฐ์ ๋ฐ๋ผ ์๋์ผ๋ก ์ด ๊ฐ์ ์กฐ์ */
}
/* auto-fit: ๋น ๊ณต๊ฐ ์ฑ์ฐ๊ธฐ */
.grid-auto-fit {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
/* auto-fill๊ณผ ๋น์ทํ์ง๋ง ๋น ํธ๋์ ๋๋ ค์ ์ฑ์ */
}
auto-fit: ๋น ํธ๋์ 0์ผ๋ก ๋ง๋ค๊ณ , ๊ธฐ์กด ์์ดํ ๋ค์ด ๊ณต๊ฐ์ ์ฑ์
๋ฐ์ํ ๊ทธ๋ฆฌ๋๋ฅผ ๋ง๋ค ๋ ์ ๋ง ์ ์ฉํด! ๐
๐ gap ์์ฑ: ๊ฐ๊ฒฉ ์กฐ์
์์ดํ ์ฌ์ด์ ๊ฐ๊ฒฉ์ ์กฐ์ ํ๋ ๊ฑด ์ ๋ง ์ฌ์! gap ์์ฑ ํ๋๋ฉด ๋์ด์ผ.
/* ํ๊ณผ ์ด ๊ฐ๊ฒฉ ๋์ผํ๊ฒ */
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
/* ํ๊ณผ ์ด ๊ฐ๊ฒฉ ๋ค๋ฅด๊ฒ */
.grid-different {
display: grid;
grid-template-columns: repeat(3, 1fr);
row-gap: 30px; /* ํ ๊ฐ๊ฒฉ */
column-gap: 20px; /* ์ด ๊ฐ๊ฒฉ */
/* ๋๋ ๋จ์ถ ํํ */
gap: 30px 20px; /* row column */
}
๐ฏ ์์ดํ ๋ฐฐ์น: grid-column๊ณผ grid-row
์ด์ ๊ฐ๋ณ ์์ดํ ์ ์ํ๋ ์์น์ ๋ฐฐ์นํด๋ณผ๊น? ์ด๊ฒ ๊ทธ๋ฆฌ๋์ ์ง์ง ๊ฐ๋ ฅํ ๊ธฐ๋ฅ์ด์ผ! ๐ช
/* ํน์ ์์ดํ
์ ์ฌ๋ฌ ์นธ์ ๊ฑธ์น๊ฒ */
.item-1 {
grid-column: 1 / 3; /* 1๋ฒ ๋ผ์ธ๋ถํฐ 3๋ฒ ๋ผ์ธ๊น์ง */
/* ๋๋ */
grid-column: span 2; /* 2์นธ ์ฐจ์ง */
}
.item-2 {
grid-row: 1 / 3; /* ์ธ๋ก๋ก 2์นธ */
}
/* ํน์ ์์น์ ์ ํํ ๋ฐฐ์น */
.item-3 {
grid-column: 2 / 4;
grid-row: 2 / 4;
/* 2-4์ด, 2-4ํ ์์ญ ์ฐจ์ง */
}
/* ๋จ์ถ ํํ */
.item-4 {
grid-area: 1 / 1 / 3 / 3;
/* row-start / column-start / row-end / column-end */
}
๐๏ธ grid-template-areas: ์์ญ ์ด๋ฆ ์ง์
์ด๊ฑด ์ ๋ง ์ง๊ด์ ์ด๊ณ ๋ฉ์ง ๊ธฐ๋ฅ์ด์ผ! ๋ ์ด์์์ ์๊ฐ์ ์ผ๋ก ์ ์ํ ์ ์๊ฑฐ๋ . ๐
/* ์ปจํ
์ด๋์ ์์ญ ์ ์ */
.container {
display: grid;
grid-template-columns: 200px 1fr 200px;
grid-template-rows: auto 1fr auto;
grid-template-areas:
"header header header"
"sidebar main aside"
"footer footer footer";
gap: 20px;
min-height: 100vh;
}
/* ๊ฐ ์์ดํ
์ ์์ญ ํ ๋น */
.header {
grid-area: header;
background: #667eea;
padding: 20px;
}
.sidebar {
grid-area: sidebar;
background: #f5f5f5;
padding: 20px;
}
.main {
grid-area: main;
background: white;
padding: 20px;
}
.aside {
grid-area: aside;
background: #f5f5f5;
padding: 20px;
}
.footer {
grid-area: footer;
background: #333;
color: white;
padding: 20px;
}
/* ๋ฐ์ํ์ผ๋ก ๋ ์ด์์ ๋ณ๊ฒฝ */
@media (max-width: 768px) {
.container {
grid-template-columns: 1fr;
grid-template-areas:
"header"
"main"
"sidebar"
"aside"
"footer";
}
}
โข ์ฝ๋ ๊ฐ๋ ์ฑ์ด ์์ฒญ ์ข์์ง
โข ๋ฐ์ํ ๋ณ๊ฒฝ์ด ์ ๋ง ์ฌ์
โข ํ ํ์ ํ ๋ ์ดํดํ๊ธฐ ์ฌ์
โข ์ ์ง๋ณด์๊ฐ ํธํจ
๐จ ์ค์ ์์ : ์ด๋ฏธ์ง ๊ฐค๋ฌ๋ฆฌ
์, ์ด์ ๋ฐฐ์ด ๊ฑธ๋ก ๋ฉ์ง ์ด๋ฏธ์ง ๊ฐค๋ฌ๋ฆฌ๋ฅผ ๋ง๋ค์ด๋ณผ๊น? ๐ธ
<div class="gallery">
<div class="gallery-item item-1">Image 1</div>
<div class="gallery-item item-2">Image 2</div>
<div class="gallery-item item-3">Image 3</div>
<div class="gallery-item item-4">Image 4</div>
<div class="gallery-item item-5">Image 5</div>
<div class="gallery-item item-6">Image 6</div>
</div>
/* CSS */
.gallery {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 15px;
padding: 20px;
}
.gallery-item {
background: #e0e0e0;
padding: 20px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
min-height: 200px;
transition: transform 0.3s;
}
.gallery-item:hover {
transform: scale(1.05);
}
/* ํน์ ์์ดํ
๊ฐ์กฐ */
.item-1 {
grid-column: span 2;
grid-row: span 2;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
font-size: 24px;
}
/* ํ๋ธ๋ฆฟ */
@media (max-width: 768px) {
.gallery {
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.item-1 {
grid-column: span 1;
grid-row: span 1;
}
}
/* ๋ชจ๋ฐ์ผ */
@media (max-width: 480px) {
.gallery {
grid-template-columns: 1fr;
}
}
๐ค ๊ทธ๋ฆฌ๋์ ํ๋ ์ค๋ฐ์ค ํจ๊ป ์ฌ์ฉํ๊ธฐ
์ฌ๊ธฐ์ ์ค์ํ ํฌ์ธํธ! ๊ทธ๋ฆฌ๋์ ํ๋ ์ค๋ฐ์ค๋ ๊ฒฝ์ ๊ด๊ณ๊ฐ ์๋์ผ. ์คํ๋ ค ํจ๊ป ์ฌ์ฉํ๋ฉด ์๋์ง๊ฐ ์์ฒญ๋๊ฑฐ๋ ! ๐ฏ
์ผ๋ฐ์ ์ผ๋ก ์ด๋ ๊ฒ ๊ตฌ๋ถํด์ ์จ:
๊ทธ๋ฆฌ๋ - ์ ์ฒด ํ์ด์ง ๋ ์ด์์, ๋ณต์กํ 2์ฐจ์ ๊ตฌ์กฐ
ํ๋ ์ค๋ฐ์ค - ์ปดํฌ๋ํธ ๋ด๋ถ, 1์ฐจ์ ์ ๋ ฌ
์๋ฅผ ๋ค์ด, ๊ทธ๋ฆฌ๋๋ก ์ ์ฒด ํ์ด์ง ๊ตฌ์กฐ๋ฅผ ์ก๊ณ , ๊ฐ ์์ญ ์์์๋ ํ๋ ์ค๋ฐ์ค๋ก ์ธ๋ถ ์์๋ค์ ๋ฐฐ์นํ๋ ๊ฑฐ์ง!
/* ์ ์ฒด ๋ ์ด์์์ ๊ทธ๋ฆฌ๋๋ก */
.page-layout {
display: grid;
grid-template-columns: 250px 1fr;
grid-template-rows: 80px 1fr 60px;
grid-template-areas:
"header header"
"sidebar main"
"footer footer";
min-height: 100vh;
gap: 20px;
}
/* ํค๋ ๋ด๋ถ๋ ํ๋ ์ค๋ฐ์ค๋ก */
.header {
grid-area: header;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 30px;
background: #667eea;
color: white;
}
.header-nav {
display: flex;
gap: 30px;
}
/* ์ฌ์ด๋๋ฐ ๋ฉ๋ด๋ ํ๋ ์ค๋ฐ์ค */
.sidebar {
grid-area: sidebar;
display: flex;
flex-direction: column;
gap: 10px;
padding: 20px;
background: #f5f5f5;
}
.sidebar-item {
display: flex;
align-items: center;
gap: 10px;
padding: 12px;
border-radius: 8px;
transition: background 0.3s;
}
.sidebar-item:hover {
background: #e0e0e0;
}
/* ๋ฉ์ธ ์ฝํ
์ธ ๋ ๊ทธ๋ฆฌ๋๋ก ์นด๋ ๋ฐฐ์น */
.main {
grid-area: main;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
padding: 20px;
}
/* ๊ฐ ์นด๋ ๋ด๋ถ๋ ํ๋ ์ค๋ฐ์ค */
.card {
display: flex;
flex-direction: column;
padding: 20px;
background: white;
border-radius: 12px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}
.card-content {
flex: 1;
}
.card-footer {
display: flex;
justify-content: flex-end;
gap: 10px;
margin-top: 15px;
}
/* ํธํฐ๋ ํ๋ ์ค๋ฐ์ค */
.footer {
grid-area: footer;
display: flex;
justify-content: center;
align-items: center;
background: #333;
color: white;
}
โข ์ฝ๋๊ฐ ๊น๋ํ๊ณ ์ดํดํ๊ธฐ ์ฌ์
โข ์ ์ง๋ณด์๊ฐ ํธํจ
โข ๋ฐ์ํ ๋์์ด ์์ฐ์ค๋ฌ์
โข ์ฑ๋ฅ๋ ์ฐ์ํจ
๐ฏ ์ธ์ ๋ฌด์์ ์ฌ์ฉํ ๊น?
CSS Grid๋ฅผ ์ฌ์ฉํ์ธ์ ๐
โข 2์ฐจ์ ๋ ์ด์์์ด ํ์ํ ๋
โข ์ ์ฒด ํ์ด์ง ๊ตฌ์กฐ๋ฅผ ์ก์ ๋
โข ๋ณต์กํ ๋ ์ด์์ ํจํด
โข ๊ฐค๋ฌ๋ฆฌ, ๋์๋ณด๋
โข ๋งค๊ฑฐ์ง ์คํ์ผ ๋ ์ด์์
โข ํ๊ณผ ์ด์ ๋์์ ์ ์ดํด์ผ ํ ๋
Flexbox๋ฅผ ์ฌ์ฉํ์ธ์ ๐ช
โข 1์ฐจ์ ๋ ์ด์์์ด๋ฉด ์ถฉ๋ถํ ๋
โข ๋ค๋น๊ฒ์ด์
๋ฐ
โข ์นด๋ ๋ด๋ถ ์์ ๋ฐฐ์น
โข ๋ฒํผ ๊ทธ๋ฃน
โข ํผ ์์ ์ ๋ ฌ
โข ๊ฐ๋จํ ์ ๋ ฌ์ด ํ์ํ ๋
๐ฑ ๋ฐ์ํ ๋์์ธ ๊ตฌํํ๊ธฐ
์ด์ ์ ๋ง ์ค์ํ ๋ถ๋ถ์ด์ผ! ์์ฆ์ ๋ชจ๋ฐ์ผ ํธ๋ํฝ์ด ๋ฐ์คํฌํฑ์ ๋์ด์ฐ๊ฑฐ๋ . ๊ทธ๋์ ๋ฐ์ํ ๋์์ธ์ ์ ํ์ด ์๋๋ผ ํ์์ผ! ๐ฑ๐ป
๊ทธ๋ฆฌ๋์ ํ๋ ์ค๋ฐ์ค๋ ๋ฐ์ํ ๋์์ธ์ ๊ตฌํํ๋ ๋ฐ ์ ๋ง ๊ฐ๋ ฅํ ๋๊ตฌ์ผ. ๋ฏธ๋์ด ์ฟผ๋ฆฌ์ ํจ๊ป ์ฌ์ฉํ๋ฉด ์๋ฒฝํ์ง!
๐จ ๋ชจ๋ฐ์ผ ํผ์คํธ ์ ๊ทผ๋ฒ
์์ฆ ํธ๋ ๋๋ "๋ชจ๋ฐ์ผ ํผ์คํธ(Mobile First)"์ผ. ๋ชจ๋ฐ์ผ ํ๋ฉด์ ๊ธฐ์ค์ผ๋ก ๋์์ธํ๊ณ , ํฐ ํ๋ฉด์ผ๋ก ๊ฐ์๋ก ๊ธฐ๋ฅ์ ์ถ๊ฐํ๋ ๊ฑฐ์ง!
/* ๊ธฐ๋ณธ ์คํ์ผ (๋ชจ๋ฐ์ผ) */
.container {
display: grid;
grid-template-columns: 1fr;
gap: 15px;
padding: 15px;
}
.card {
padding: 15px;
}
/* ํ๋ธ๋ฆฟ (768px ์ด์) */
@media (min-width: 768px) {
.container {
grid-template-columns: repeat(2, 1fr);
gap: 20px;
padding: 20px;
}
.card {
padding: 20px;
}
}
/* ๋ฐ์คํฌํฑ (1024px ์ด์) */
@media (min-width: 1024px) {
.container {
grid-template-columns: repeat(3, 1fr);
gap: 30px;
padding: 30px;
}
}
/* ๋ํ ํ๋ฉด (1440px ์ด์) */
@media (min-width: 1440px) {
.container {
grid-template-columns: repeat(4, 1fr);
max-width: 1400px;
margin: 0 auto;
}
}
๐ ์๋ ๋ฐ์ํ ๊ทธ๋ฆฌ๋
๋ฏธ๋์ด ์ฟผ๋ฆฌ ์์ด๋ ๋ฐ์ํ์ ๋ง๋ค ์ ์์ด! auto-fit๊ณผ minmax()๋ฅผ ์กฐํฉํ๋ฉด ๋ง๋ฒ์ฒ๋ผ ์๋ํด. โจ
/* ์์ ์๋ ๋ฐ์ํ! */
.auto-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 20px;
}
/* ์ด๊ฒ ๋! ํ๋ฉด ํฌ๊ธฐ์ ๋ฐ๋ผ ์๋์ผ๋ก ์ด ๊ฐ์๊ฐ ์กฐ์ ๋จ */
/* ์กฐ๊ธ ๋ ์ธ๋ฐํ ์ ์ด */
.smart-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
gap: clamp(15px, 3vw, 30px);
padding: clamp(15px, 3vw, 30px);
}
/* clamp()๋ก ๊ฐ๊ฒฉ๋ ์ ์ฐํ๊ฒ! */
๐ ์ปจํ ์ด๋ ์ฟผ๋ฆฌ (์ต์ ๊ธฐ์ !)
2023๋ ๋ถํฐ ์ฃผ์ ๋ธ๋ผ์ฐ์ ์์ ์ง์ํ๊ธฐ ์์ํ ์ปจํ ์ด๋ ์ฟผ๋ฆฌ! ์ด๊ฑด ์ ๋ง ํ์ ์ ์ด์ผ. ๋ทฐํฌํธ๊ฐ ์๋๋ผ ๋ถ๋ชจ ์ปจํ ์ด๋์ ํฌ๊ธฐ์ ๋ฐ๋ผ ์คํ์ผ์ ๋ณ๊ฒฝํ ์ ์๊ฑฐ๋ ! ๐
/* ์ปจํ
์ด๋ ์ ์ */
.card-container {
container-type: inline-size;
container-name: card;
}
/* ์ปจํ
์ด๋ ํฌ๊ธฐ์ ๋ฐ๋ฅธ ์คํ์ผ */
.card {
display: flex;
flex-direction: column;
gap: 15px;
}
/* ์ปจํ
์ด๋๊ฐ 500px ์ด์์ผ ๋ */
@container card (min-width: 500px) {
.card {
flex-direction: row;
align-items: center;
}
.card-image {
width: 200px;
}
.card-content {
flex: 1;
}
}
/* ์ปจํ
์ด๋๊ฐ 700px ์ด์์ผ ๋ */
@container card (min-width: 700px) {
.card {
padding: 30px;
}
.card-image {
width: 300px;
}
}
๐ช ์ค์ ๋ฐ์ํ ๋ ์ด์์
/* ์ ์ฒด ๋ ์ด์์ */
.page {
display: grid;
grid-template-areas:
"header"
"main"
"sidebar"
"footer";
gap: 20px;
padding: 20px;
}
.header { grid-area: header; }
.main { grid-area: main; }
.sidebar { grid-area: sidebar; }
.footer { grid-area: footer; }
/* ํ๋ธ๋ฆฟ: ์ฌ์ด๋๋ฐ๋ฅผ ์์ผ๋ก */
@media (min-width: 768px) {
.page {
grid-template-columns: 1fr 300px;
grid-template-areas:
"header header"
"main sidebar"
"footer footer";
}
}
/* ๋ฐ์คํฌํฑ: ๋ ๋์ ๋ ์ด์์ */
@media (min-width: 1024px) {
.page {
grid-template-columns: 250px 1fr 300px;
grid-template-areas:
"header header header"
"nav main sidebar"
"footer footer footer";
max-width: 1400px;
margin: 0 auto;
}
}
/* ๋ฉ์ธ ์ฝํ
์ธ ๋ด๋ถ ๊ทธ๋ฆฌ๋ */
.main {
display: grid;
grid-template-columns: 1fr;
gap: 20px;
}
@media (min-width: 768px) {
.main {
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
}
/* ๋ค๋น๊ฒ์ด์
*/
.nav {
display: flex;
flex-direction: column;
gap: 10px;
}
@media (min-width: 1024px) {
.nav {
position: sticky;
top: 20px;
}
}
/* ์นด๋ ๋ ์ด์์ */
.card {
display: flex;
flex-direction: column;
background: white;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.card-image {
width: 100%;
height: 200px;
object-fit: cover;
}
.card-content {
padding: 20px;
flex: 1;
display: flex;
flex-direction: column;
gap: 10px;
}
.card-footer {
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px 20px;
border-top: 1px solid #e0e0e0;
}
/* ๊ฐ๋ก ์นด๋ (ํฐ ํ๋ฉด) */
@media (min-width: 768px) {
.card-horizontal {
flex-direction: row;
}
.card-horizontal .card-image {
width: 300px;
height: auto;
}
}
๐ฏ ์ฑ๋ฅ ์ต์ ํ์ ๋ฒ ์คํธ ํ๋ํฐ์ค
๋ ์ด์์์ ๋ง๋๋ ๊ฒ๋ ์ค์ํ์ง๋ง, ์ฑ๋ฅ๋ ์ ๊ฒฝ ์จ์ผ ํด! ์๋ฌด๋ฆฌ ์์ ๋ ์ด์์์ด๋ผ๋ ๋๋ฆฌ๋ฉด ์ฌ์ฉ์๋ค์ด ๋ ๋๊ฑฐ๋ . ๐
โก ์ฑ๋ฅ ์ต์ ํ ํ
1. ๋ถํ์ํ ์ค์ฒฉ ํผํ๊ธฐ
/* ๋์ ์ โ */
.container {
display: grid;
}
.wrapper {
display: grid;
}
.inner {
display: grid;
}
/* ์ข์ ์ โ
*/
.container {
display: grid;
/* ํ ๋ฒ์ ์ํ๋ ๋ ์ด์์ ๊ตฌํ */
}2. will-change ์ ์คํ๊ฒ ์ฌ์ฉ
/* ์ ๋๋ฉ์ด์
์ด ์๋ ์์์๋ง */
.animated-card {
will-change: transform;
transition: transform 0.3s;
}
.animated-card:hover {
transform: scale(1.05);
}3. content-visibility๋ก ๋ ๋๋ง ์ต์ ํ
/* ํ๋ฉด ๋ฐ ์ฝํ
์ธ ๋ ๋๋ง ์ง์ฐ */
.card {
content-visibility: auto;
contain-intrinsic-size: 0 500px;
}4. ๊ณ ์ ํฌ๊ธฐ๋ณด๋ค ์ ์ฐํ ํฌ๊ธฐ
/* ๋์ ์ โ */
.grid {
grid-template-columns: 300px 300px 300px;
}
/* ์ข์ ์ โ
*/
.grid {
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
๐ ์ฝ๋ฉ ๋ฒ ์คํธ ํ๋ํฐ์ค
1. ์๋ฏธ ์๋ ํด๋์ค๋ช ์ฌ์ฉ
/* ๋์ ์ โ */
.box1, .box2, .container1 { }
/* ์ข์ ์ โ
*/
.product-grid, .card-container, .nav-menu { }2. CSS ๋ณ์๋ก ์ผ๊ด์ฑ ์ ์ง
:root {
--grid-gap: 20px;
--card-padding: 20px;
--border-radius: 12px;
--primary-color: #667eea;
}
.grid {
display: grid;
gap: var(--grid-gap);
}
.card {
padding: var(--card-padding);
border-radius: var(--border-radius);
background: var(--primary-color);
}3. ๋ชจ๋ฐ์ผ ํผ์คํธ ์์ฑ
/* ๊ธฐ๋ณธ (๋ชจ๋ฐ์ผ) */
.container {
display: grid;
grid-template-columns: 1fr;
}
/* ์ ์ง์ ํฅ์ */
@media (min-width: 768px) {
.container {
grid-template-columns: repeat(2, 1fr);
}
}
@media (min-width: 1024px) {
.container {
grid-template-columns: repeat(3, 1fr);
}
}4. ์ฃผ์์ผ๋ก ์๋ ๋ช ํํ
/* ์ ํ ์นด๋ ๊ทธ๋ฆฌ๋ - ๋ฐ์ํ 3์ด ๋ ์ด์์ */
.product-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 24px;
/* ๋ชจ๋ฐ์ผ์์ ํจ๋ฉ ์กฐ์ */
padding: clamp(16px, 4vw, 32px);
}
๐ ํํ ์ค์์ ํด๊ฒฐ๋ฒ
์ค์ 1: ๊ทธ๋ฆฌ๋ ์์ดํ ์ด ๋์น๋ ๋ฌธ์
/* ๋ฌธ์ */
.grid-item {
width: 500px; /* ๊ณ ์ ๋๋น */
}
/* ํด๊ฒฐ */
.grid-item {
max-width: 100%; /* ์ปจํ
์ด๋๋ฅผ ๋์ง ์์ */
overflow: hidden; /* ๋ด์ฉ๋ฌผ ๋์นจ ๋ฐฉ์ง */
}์ค์ 2: ํ๋ ์ค ์์ดํ ์ด ์ฐ๊ทธ๋ฌ์ง
/* ๋ฌธ์ */
.flex-item {
/* flex-shrink ๊ธฐ๋ณธ๊ฐ 1 */
}
/* ํด๊ฒฐ */
.flex-item {
flex-shrink: 0; /* ์ค์ด๋ค์ง ์์ */
min-width: 0; /* ๋๋ ์ต์ ๋๋น ์ค์ */
}์ค์ 3: ์ด๋ฏธ์ง ๋น์จ ๊นจ์ง
/* ๋ฌธ์ */
img {
width: 100%;
height: 100%;
}
/* ํด๊ฒฐ */
img {
width: 100%;
height: 100%;
object-fit: cover; /* ๋น์จ ์ ์งํ๋ฉฐ ์ฑ์ฐ๊ธฐ */
}์ค์ 4: ๊ฐ๊ฒฉ ๊ณ์ฐ ์ค์
/* ๋ฌธ์ */
.container {
width: 100%;
padding: 20px;
/* ํจ๋ฉ ๋๋ฌธ์ ๋๋น ์ด๊ณผ */
}
/* ํด๊ฒฐ */
.container {
width: 100%;
padding: 20px;
box-sizing: border-box; /* ํจ๋ฉ ํฌํจ ๊ณ์ฐ */
}
๐จ ์ค์ ํ๋ก์ ํธ: ์์ ํ ์น์ฌ์ดํธ ๋ง๋ค๊ธฐ
์, ์ด์ ๋ฐฐ์ด ๋ชจ๋ ๊ฑธ ์ข ํฉํด์ ์ค์ ์น์ฌ์ดํธ๋ฅผ ๋ง๋ค์ด๋ณผ๊น? ์ด ์์ ๋ ์ค๋ฌด์์ ๋ฐ๋ก ์ฌ์ฉํ ์ ์๋ ์์ค์ด์ผ! ๐ช
<!-- HTML ๊ตฌ์กฐ -->
<div class="site-wrapper">
<header class="site-header">
<div class="header-content">
<div class="logo">MyBrand</div>
<nav class="main-nav">
<a href="#">Home</a>
<a href="#">Products</a>
<a href="#">About</a>
<a href="#">Contact</a>
</nav>
<button class="cta-button">Get Started</button>
</div>
</header>
<main class="site-main">
<section class="hero">
<div class="hero-content">
<h1>Welcome to Our Platform</h1>
<p>Build amazing websites with modern CSS</p>
<button>Learn More</button>
</div>
</section>
<section class="features">
<h2>Our Features</h2>
<div class="feature-grid">
<div class="feature-card">
<div class="feature-icon">๐</div>
<h3>Fast Performance</h3>
<p>Lightning fast load times</p>
</div>
<div class="feature-card">
<div class="feature-icon">๐ฑ</div>
<h3>Responsive Design</h3>
<p>Works on all devices</p>
</div>
<div class="feature-card">
<div class="feature-icon">๐จ</div>
<h3>Beautiful UI</h3>
<p>Modern and clean design</p>
</div>
<div class="feature-card">
<div class="feature-icon">๐</div>
<h3>Secure</h3>
<p>Enterprise-grade security</p>
</div>
</div>
</section>
<section class="products">
<h2>Our Products</h2>
<div class="product-grid">
<article class="product-card">
<div class="product-image">Image</div>
<div class="product-content">
<h3>Product 1</h3>
<p>Amazing product description</p>
<div class="product-footer">
<span class="price">$99</span>
<button>Buy Now</button>
</div>
</div>
</article>
<!-- ๋ ๋ง์ ์ ํ ์นด๋... -->
</div>
</section>
</main>
<footer class="site-footer">
<div class="footer-content">
<div class="footer-section">
<h4>About Us</h4>
<p>We create amazing web experiences</p>
</div>
<div class="footer-section">
<h4>Quick Links</h4>
<a href="#">Home</a>
<a href="#">Products</a>
<a href="#">Contact</a>
</div>
<div class="footer-section">
<h4>Contact</h4>
<p>info@example.com</p>
</div>
</div>
<div class="footer-bottom">
<p>ยฉ 2024 MyBrand. All rights reserved.</p>
</div>
</footer>
</div>
/* CSS ์คํ์ผ */
:root {
--primary-color: #667eea;
--secondary-color: #764ba2;
--text-color: #333;
--bg-color: #f8f9fa;
--card-bg: #ffffff;
--border-radius: 12px;
--box-shadow: 0 2px 10px rgba(0,0,0,0.1);
--transition: all 0.3s ease;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
color: var(--text-color);
background: var(--bg-color);
line-height: 1.6;
}
/* ํค๋ */
.site-header {
background: white;
box-shadow: var(--box-shadow);
position: sticky;
top: 0;
z-index: 100;
}
.header-content {
max-width: 1400px;
margin: 0 auto;
padding: 20px 30px;
display: flex;
justify-content: space-between;
align-items: center;
gap: 30px;
}
.logo {
font-size: 24px;
font-weight: bold;
color: var(--primary-color);
}
.main-nav {
display: flex;
gap: 30px;
}
.main-nav a {
color: var(--text-color);
text-decoration: none;
transition: var(--transition);
}
.main-nav a:hover {
color: var(--primary-color);
}
.cta-button {
padding: 12px 24px;
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
color: white;
border: none;
border-radius: var(--border-radius);
cursor: pointer;
font-weight: bold;
transition: var(--transition);
}
.cta-button:hover {
transform: translateY(-2px);
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}
/* ํ์ด๋ก ์น์
*/
.hero {
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
color: white;
padding: 100px 30px;
text-align: center;
}
.hero-content {
max-width: 800px;
margin: 0 auto;
}
.hero h1 {
font-size: clamp(32px, 5vw, 56px);
margin-bottom: 20px;
}
.hero p {
font-size: clamp(18px, 2vw, 24px);
margin-bottom: 30px;
opacity: 0.9;
}
.hero button {
padding: 15px 40px;
background: white;
color: var(--primary-color);
border: none;
border-radius: var(--border-radius);
font-size: 18px;
font-weight: bold;
cursor: pointer;
transition: var(--transition);
}
.hero button:hover {
transform: scale(1.05);
}
/* ๊ธฐ๋ฅ ์น์
*/
.features {
max-width: 1400px;
margin: 0 auto;
padding: 80px 30px;
}
.features h2 {
text-align: center;
font-size: clamp(28px, 4vw, 42px);
margin-bottom: 50px;
}
.feature-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 30px;
}
.feature-card {
background: var(--card-bg);
padding: 40px 30px;
border-radius: var(--border-radius);
box-shadow: var(--box-shadow);
text-align: center;
transition: var(--transition);
}
.feature-card:hover {
transform: translateY(-10px);
box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}
.feature-icon {
font-size: 48px;
margin-bottom: 20px;
}
.feature-card h3 {
font-size: 24px;
margin-bottom: 15px;
color: var(--primary-color);
}
/* ์ ํ ์น์
*/
.products {
max-width: 1400px;
margin: 0 auto;
padding: 80px 30px;
background: white;
}
.products h2 {
text-align: center;
font-size: clamp(28px, 4vw, 42px);
margin-bottom: 50px;
}
.product-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 30px;
}
.product-card {
background: var(--card-bg);
border-radius: var(--border-radius);
overflow: hidden;
box-shadow: var(--box-shadow);
transition: var(--transition);
display: flex;
flex-direction: column;
}
.product-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}
.product-image {
width: 100%;
height: 250px;
background: linear-gradient(135deg, #667eea, #764ba2);
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 24px;
}
.product-content {
padding: 25px;
flex: 1;
display: flex;
flex-direction: column;
}
.product-content h3 {
font-size: 22px;
margin-bottom: 10px;
}
.product-content p {
flex: 1;
margin-bottom: 20px;
color: #666;
}
.product-footer {
display: flex;
justify-content: space-between;
align-items: center;
}
.price {
font-size: 28px;
font-weight: bold;
color: var(--primary-color);
}
.product-footer button {
padding: 10px 25px;
background: var(--primary-color);
color: white;
border: none;
border-radius: var(--border-radius);
cursor: pointer;
transition: var(--transition);
}
.product-footer button:hover {
background: var(--secondary-color);
}
/* ํธํฐ */
.site-footer {
background: #2c3e50;
color: white;
padding: 60px 30px 20px;
}
.footer-content {
max-width: 1400px;
margin: 0 auto;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 40px;
margin-bottom: 40px;
}
.footer-section h4 {
font-size: 20px;
margin-bottom: 20px;
}
.footer-section a {
display: block;
color: rgba(255,255,255,0.8);
text-decoration: none;
margin-bottom: 10px;
transition: var(--transition);
}
.footer-section a:hover {
color: white;
padding-left: 5px;
}
.footer-bottom {
max-width: 1400px;
margin: 0 auto;
padding-top: 20px;
border-top: 1px solid rgba(255,255,255,0.1);
text-align: center;
color: rgba(255,255,255,0.6);
}
/* ๋ฐ์ํ */
@media (max-width: 768px) {
.header-content {
flex-direction: column;
gap: 20px;
}
.main-nav {
flex-direction: column;
text-align: center;
gap: 15px;
}
.hero {
padding: 60px 20px;
}
.features,
.products {
padding: 50px 20px;
}
.feature-grid,
.product-grid {
grid-template-columns: 1fr;
}
}
@media (max-width: 480px) {
.product-grid {
grid-template-columns: 1fr;
}
.footer-content {
grid-template-columns: 1fr;
text-align: center;
}
}
โข ๊ทธ๋ฆฌ๋์ ํ๋ ์ค๋ฐ์ค์ ์กฐํ๋ก์ด ์ฌ์ฉ
โข CSS ๋ณ์๋ก ์ผ๊ด๋ ๋์์ธ ์์คํ
โข ๋ชจ๋ํ UI/UX
โข ์ค๋ฌด์์ ๋ฐ๋ก ์ฌ์ฉ ๊ฐ๋ฅ
โข ์ ๊ทผ์ฑ ๊ณ ๋ ค
โข ์ฑ๋ฅ ์ต์ ํ
๐ ๏ธ ๊ฐ๋ฐ ๋๊ตฌ์ ๋ฆฌ์์ค
๋ ์ด์์ ๊ฐ๋ฐ์ ๋ ์ฝ๊ฒ ๋ง๋ค์ด์ฃผ๋ ๋๊ตฌ๋ค์ ์๊ฐํ ๊ฒ! ์ด๋ฐ ๋๊ตฌ๋ค์ ํ์ฉํ๋ฉด ๊ฐ๋ฐ ์๋๊ฐ ํจ์ฌ ๋นจ๋ผ์ ธ. โก
๐จ ์ ์ฉํ ์จ๋ผ์ธ ๋๊ตฌ
โข cssgrid-generator.netlify.app
โข ์๊ฐ์ ์ผ๋ก ๊ทธ๋ฆฌ๋ ๋ ์ด์์ ์์ฑ
โข ์ฝ๋ ์๋ ์์ฑ
2. Flexbox Froggy
โข flexboxfroggy.com
โข ๊ฒ์์ผ๋ก ํ๋ ์ค๋ฐ์ค ํ์ต
โข ์ฌ๋ฏธ์๊ฒ ๋ฐฐ์ธ ์ ์์
3. Grid Garden
โข cssgridgarden.com
โข ๊ฒ์์ผ๋ก ๊ทธ๋ฆฌ๋ ํ์ต
โข ๋จ๊ณ๋ณ ํ์ต ๊ฐ๋ฅ
4. Can I Use
โข caniuse.com
โข ๋ธ๋ผ์ฐ์ ํธํ์ฑ ํ์ธ
โข ํ์ ๋๊ตฌ!
5. CodePen
โข codepen.io
โข ์ค์๊ฐ ์ฝ๋ ํ ์คํธ
โข ๋ค๋ฅธ ๊ฐ๋ฐ์ ์ฝ๋ ์ฐธ๊ณ
6. CSS Tricks
โข css-tricks.com
โข ์ต์ CSS ๊ธฐ๋ฒ
โข ํํ ๋ฆฌ์ผ๊ณผ ๊ฐ์ด๋
๐ ํ์ต ๋ฆฌ์์ค
โข MDN Web Docs (developer.mozilla.org)
โข W3C CSS Grid Specification
โข W3C Flexbox Specification
์จ๋ผ์ธ ๊ฐ์
โข Wes Bos - CSS Grid Course (๋ฌด๋ฃ!)
โข Scrimba - Learn Flexbox
โข freeCodeCamp - Responsive Web Design
์ ํ๋ธ ์ฑ๋
โข Kevin Powell
โข Web Dev Simplified
โข Traversy Media
๋ธ๋ก๊ทธ
โข Smashing Magazine
โข A List Apart
โข CSS Tricks
๐ง ๋ธ๋ผ์ฐ์ ๊ฐ๋ฐ์ ๋๊ตฌ ํ์ฉ
โข F12 ๋๋ Ctrl+Shift+I (Windows)
โข Cmd+Option+I (Mac)
์ ์ฉํ ๊ธฐ๋ฅ๋ค
โข Elements ํญ์์ ์ค์๊ฐ CSS ์์
โข Grid/Flexbox ์ค๋ฒ๋ ์ด ํ์
โข ๋ฐ์ํ ๋์์ธ ๋ชจ๋ (Ctrl+Shift+M)
โข CSS ๋ณ๊ฒฝ์ฌํญ ์ถ์
โข ์ฑ๋ฅ ๋ถ์ ๋๊ตฌ
Grid Inspector
โข ๊ทธ๋ฆฌ๋ ๋ผ์ธ ์๊ฐํ
โข ์์ญ ์ด๋ฆ ํ์
โข ๊ฐ๊ฒฉ ์ธก์
Flexbox Inspector
โข ์ฃผ์ ์ถ๊ณผ ๊ต์ฐจ ์ถ ํ์
โข ์์ดํ ํฌ๊ธฐ ํ์ธ
โข ์ ๋ ฌ ์ํ ์๊ฐํ
๐ ๋ฏธ๋์ CSS ๋ ์ด์์
CSS๋ ๊ณ์ ์งํํ๊ณ ์์ด! ์์ผ๋ก ๋์ฌ ๊ธฐ๋ฅ๋ค์ ๋ฏธ๋ฆฌ ์์๋๋ฉด ์ข๊ฒ ์ง? ๐
๐ฎ ์ฃผ๋ชฉํ ๋งํ ์๋ก์ด ๊ธฐ๋ฅ
1. Subgrid
/* ์ค์ฒฉ๋ ๊ทธ๋ฆฌ๋๊ฐ ๋ถ๋ชจ ๊ทธ๋ฆฌ๋ ๋ผ์ธ ์ฌ์ฉ */
.parent {
display: grid;
grid-template-columns: repeat(3, 1fr);
}
.child {
display: grid;
grid-template-columns: subgrid;
/* ๋ถ๋ชจ์ ๊ทธ๋ฆฌ๋ ๋ผ์ธ์ ๊ทธ๋๋ก ์ฌ์ฉ! */
}2. Container Queries
/* ๋ทฐํฌํธ๊ฐ ์๋ ์ปจํ
์ด๋ ๊ธฐ์ค */
@container (min-width: 500px) {
.card {
display: flex;
}
}3. :has() ์ ํ์
/* ํน์ ์์์ ๊ฐ์ง ๋ถ๋ชจ ์ ํ */
.card:has(img) {
grid-column: span 2;
}
/* ์ด๋ฏธ์ง๊ฐ ์๋ ์นด๋๋ง 2์นธ ์ฐจ์ง */4. CSS Nesting
/* Sass์ฒ๋ผ ์ค์ฒฉ ๊ฐ๋ฅ */
.card {
padding: 20px;
& .title {
font-size: 24px;
}
&:hover {
transform: scale(1.05);
}
}5. Cascade Layers
/* CSS ์ฐ์ ์์๋ฅผ ๋ ์ด์ด๋ก ๊ด๋ฆฌ */
@layer base, components, utilities;
@layer base {
h1 { font-size: 2em; }
}
@layer components {
.card { padding: 20px; }
}
๐ก ์์ผ๋ก์ ํ์ต ๋ฐฉํฅ
โข ๊ทธ๋ฆฌ๋์ ํ๋ ์ค๋ฐ์ค ์๋ฒฝ ์ดํด
โข ๋ฐ์ํ ๋์์ธ ์์น ์์ง
โข ์ ๊ทผ์ฑ ๊ณ ๋ คํ ๋งํฌ์
2. ์ค์ ๊ฒฝํ ์๊ธฐ
โข ๊ฐ์ธ ํ๋ก์ ํธ ์งํ
โข ์คํ์์ค ๊ธฐ์ฌ
โข ํฌํธํด๋ฆฌ์ค ์ ์
3. ์ต์ ํธ๋ ๋ ํ๋ก์ฐ
โข CSS ๋ช ์ธ ๋ณ๊ฒฝ์ฌํญ ์ถ์
โข ๊ฐ๋ฐ ์ปค๋ฎค๋ํฐ ์ฐธ์ฌ
โข ์ปจํผ๋ฐ์ค ์์ ์์ฒญ
4. ์ฑ๋ฅ ์ต์ ํ ํ์ต
โข ๋ ๋๋ง ์ฑ๋ฅ ์ดํด
โข ๋ ์ด์์ ์ฌํํธ ์ต์ํ
โข ํฌ๋ฆฌํฐ์ปฌ CSS ์ต์ ํ
5. ๋์์ธ ๊ฐ๊ฐ ํค์ฐ๊ธฐ
โข UI/UX ๊ธฐ๋ณธ ์์น ํ์ต
โข ์ข์ ๋์์ธ ์ฌ๋ก ๋ถ์
โข ํ์ดํฌ๊ทธ๋ํผ์ ์์ ์ด๋ก
๐ ๋ง๋ฌด๋ฆฌํ๋ฉฐ
์! ์ฌ๊ธฐ๊น์ง ์ ๋ง ๊ธด ์ฌ์ ์ด์์ด. ๊ณ ์ํ์ด! ๐
CSS ๊ทธ๋ฆฌ๋์ ํ๋ ์ค๋ฐ์ค๋ ํ๋ ์น ๊ฐ๋ฐ์ ํต์ฌ ๊ธฐ์ ์ด์ผ. ์ด ๋ ๊ฐ์ง๋ง ์ ๋๋ก ์ตํ๋ ๋๋ถ๋ถ์ ๋ ์ด์์์ ์์ ์์ฌ๋ก ๋ง๋ค ์ ์์ด. ๐ช
๊ธฐ์ตํด์ผ ํ ํต์ฌ ํฌ์ธํธ๋ฅผ ์ ๋ฆฌํด๋ณผ๊น?
โข 1์ฐจ์ ๋ ์ด์์ (ํ ๋๋ ์ด)
โข ๋ค๋น๊ฒ์ด์ , ๋ฒํผ ๊ทธ๋ฃน
โข ์นด๋ ๋ด๋ถ ์์ ์ ๋ ฌ
โข ๊ฐ๋จํ ์ ๋ ฌ์ด ํ์ํ ๋
CSS Grid๋ ์ด๋ด ๋!
โข 2์ฐจ์ ๋ ์ด์์ (ํ๊ณผ ์ด ๋์)
โข ์ ์ฒด ํ์ด์ง ๊ตฌ์กฐ
โข ๊ฐค๋ฌ๋ฆฌ, ๋์๋ณด๋
โข ๋ณต์กํ ๋ ์ด์์ ํจํด
ํจ๊ป ์ฌ์ฉํ๋ฉด ์ต๊ฐ!
โข ๊ทธ๋ฆฌ๋๋ก ํฐ ๊ตฌ์กฐ ์ก๊ธฐ
โข ํ๋ ์ค๋ฐ์ค๋ก ์ธ๋ถ ์ ๋ ฌ
โข ๊ฐ ๊ธฐ์ ์ ์ฅ์ ํ์ฉ
โข ๊น๋ํ๊ณ ์ ์ง๋ณด์ ์ฌ์ด ์ฝ๋
๋ฐ์ํ์ ํ์!
โข ๋ชจ๋ฐ์ผ ํผ์คํธ ์ ๊ทผ
โข ๋ฏธ๋์ด ์ฟผ๋ฆฌ ํ์ฉ
โข auto-fit, minmax() ์กฐํฉ
โข ์ ์ฐํ ๋จ์ ์ฌ์ฉ (fr, %, vw ๋ฑ)
๋งํ๋ ๋ถ๋ถ์ด ์๋ค๋ฉด ๊ฐ๋ฐ์ ์ปค๋ฎค๋ํฐ์ ์ง๋ฌธํ๊ฑฐ๋, ์ฌ๋ฅ๋ท์์ ์ ๋ฌธ๊ฐ์ ๋์์ ๋ฐ๋ ๊ฒ๋ ์ข์ ๋ฐฉ๋ฒ์ด์ผ. ํผ์ ๊ณ ๋ฏผํ๋ ์๊ฐ์ ์ค์ด๊ณ , ๋ ๋น ๋ฅด๊ฒ ์ฑ์ฅํ ์ ์๊ฑฐ๋ ! ๐
์น ๊ฐ๋ฐ์ ๊ณ์ ์งํํ๊ณ ์์ด. ์๋ก์ด ๊ธฐ์ ์ด ๋์ค๊ณ , ๋ ๋์ ๋ฐฉ๋ฒ๋ค์ด ๋ฑ์ฅํ์ง. ํ์ง๋ง ๊ธฐ๋ณธ๊ธฐ๊ฐ ํํํ๋ฉด ์ด๋ค ๋ณํ๋ ๋๋ ต์ง ์์. ์ง๊ธ ๋ฐฐ์ด ๊ทธ๋ฆฌ๋์ ํ๋ ์ค๋ฐ์ค๊ฐ ๋ฐ๋ก ๊ทธ ํผํผํ ๊ธฐ์ด๊ฐ ๋์ด์ค ๊ฑฐ์ผ! ๐ช
์, ์ด์ ์ฝ๋ ์๋ํฐ๋ฅผ ์ด๊ณ ์ง์ ๋ง๋ค์ด๋ณด์! ์ฝ๊ธฐ๋ง ํ๋ ๊ฒ๊ณผ ์ง์ ํด๋ณด๋ ๊ฑด ์์ ํ ๋ค๋ฅธ ๊ฒฝํ์ด๊ฑฐ๋ . ์ค์ต์ด ์ต๊ณ ์ ํ์ต ๋ฐฉ๋ฒ์ด์ผ! ๐จ
ํ์ดํ ! ๋ ํ ์ ์์ด! ๐
โข MDN Web Docs - ๊ณต์ ๋ฌธ์
โข CSS Tricks - ์ค์ ํ๊ณผ ํธ๋ฆญ
โข Flexbox Froggy - ๊ฒ์์ผ๋ก ๋ฐฐ์ฐ๊ธฐ
โข Grid Garden - ๊ทธ๋ฆฌ๋ ์ฐ์ต
์ค์ต ํ๋ซํผ
โข CodePen - ์จ๋ผ์ธ ์ฝ๋ ์๋ํฐ
โข JSFiddle - ๋น ๋ฅธ ํ ์คํธ
โข CodeSandbox - ํ๋ก์ ํธ ํ๊ฒฝ
์ปค๋ฎค๋ํฐ
โข Stack Overflow - ์ง๋ฌธ๊ณผ ๋ต๋ณ
โข Reddit r/webdev - ๊ฐ๋ฐ์ ์ปค๋ฎค๋ํฐ
โข Discord ๊ฐ๋ฐ ์๋ฒ๋ค
์ฌ๋ฅ๋ท ํ์ฉ
โข 1:1 ๋ฉํ ๋ง ๋ฐ๊ธฐ
โข ํ๋ก์ ํธ ๋ฆฌ๋ทฐ ์์ฒญ
โข ํฌํธํด๋ฆฌ์ค ์ ์ ๋์
โข ์ทจ์ ์ค๋น ์ฝ์นญ
ํ๋ณตํ ์ฝ๋ฉ ๋์ธ์! ๐โจ
๐ ๋น์ ์ ์น ๊ฐ๋ฐ ์ฌ์ ์ ์์ํฉ๋๋ค!
CSS ๊ทธ๋ฆฌ๋์ ํ๋ ์ค๋ฐ์ค๋ก ๋ฉ์ง ์น์ฌ์ดํธ๋ฅผ ๋ง๋ค์ด๋ณด์ธ์!
์ง๋ฌธ์ด๋ ๋์์ด ํ์ํ๋ค๋ฉด ์ธ์ ๋ ๊ฐ๋ฐ ์ปค๋ฎค๋ํฐ๋ ์ฌ๋ฅ๋ท์ ํ์ฉํ์ธ์! ๐ช
๊ด๋ จ ํค์๋
๋๊ธ ์์ฑ
์ด ๊ธ์ ๋ํ ์ฌ๋ฌ๋ถ์ ์๊ฐ์ ๋ค๋ ค์ฃผ์ธ์
๋ก๊ทธ์ธ์ด ํ์ํฉ๋๋ค
๋๊ธ์ ์์ฑํ๋ ค๋ฉด ๋จผ์ ๋ก๊ทธ์ธํด์ฃผ์ธ์.
๋๊ธ 0
์ง์์ธ์ ์ฒ - ์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
- ์ ์๊ถ ๋ฐ ์์ ๊ถ: ๋ณธ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ๋ ์ AI ๊ธฐ์ ๋ก ์์ฑ๋์์ผ๋ฉฐ, ๋ํ๋ฏผ๊ตญ ์ ์๊ถ๋ฒ ๋ฐ ๊ตญ์ ์ ์๊ถ ํ์ฝ์ ์ํด ๋ณดํธ๋ฉ๋๋ค.
- AI ์์ฑ ์ปจํ ์ธ ์ ๋ฒ์ ์ง์: ๋ณธ AI ์์ฑ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ์ง์ ์ฐฝ์๋ฌผ๋ก ์ธ์ ๋๋ฉฐ, ๊ด๋ จ ๋ฒ๊ท์ ๋ฐ๋ผ ์ ์๊ถ ๋ณดํธ๋ฅผ ๋ฐ์ต๋๋ค.
- ์ฌ์ฉ ์ ํ: ์ฌ๋ฅ๋ท์ ๋ช ์์ ์๋ฉด ๋์ ์์ด ๋ณธ ์ปจํ ์ธ ๋ฅผ ๋ณต์ , ์์ , ๋ฐฐํฌ, ๋๋ ์์ ์ ์ผ๋ก ํ์ฉํ๋ ํ์๋ ์๊ฒฉํ ๊ธ์ง๋ฉ๋๋ค.
- ๋ฐ์ดํฐ ์์ง ๊ธ์ง: ๋ณธ ์ปจํ ์ธ ์ ๋ํ ๋ฌด๋จ ์คํฌ๋ํ, ํฌ๋กค๋ง, ๋ฐ ์๋ํ๋ ๋ฐ์ดํฐ ์์ง์ ๋ฒ์ ์ ์ฌ์ ๋์์ด ๋ฉ๋๋ค.
- AI ํ์ต ์ ํ: ์ฌ๋ฅ๋ท์ AI ์์ฑ ์ปจํ ์ธ ๋ฅผ ํ AI ๋ชจ๋ธ ํ์ต์ ๋ฌด๋จ ์ฌ์ฉํ๋ ํ์๋ ๊ธ์ง๋๋ฉฐ, ์ด๋ ์ง์ ์ฌ์ฐ๊ถ ์นจํด๋ก ๊ฐ์ฃผ๋ฉ๋๋ค.
์์ง ๋๊ธ์ด ์์ต๋๋ค.