Ver3.0 ๐จ CSS Grid๋ก ๋ณต์กํ ๋ ์ด์์ ์ ๋ณตํ๊ธฐ

๐จ CSS Grid๋ก ๋ณต์กํ ๋ ์ด์์ ์ ๋ณตํ๊ธฐ
์น๊ตฌ์ผ, ์ด์ float์ position์ ๊ทธ๋ง! Grid์ ์ธ๊ณ๋ก ๋ ๋๋ณด์ ๐
๐ CSS Grid, ๋๋ ๋๊ตฌ๋?
์ผ, ์์งํ ๋งํด์ ์น ๋ ์ด์์ ๋ง๋ค ๋ ์ง์ง ๋จธ๋ฆฌ ์ํ์ง ์์์ด? float ์ฐ๋ฉด clearfix ํด์ผ ํ๊ณ , position absolute ์ฐ๋ฉด ๋ถ๋ชจ ์์์ relative ๊ฑธ์ด์ผ ํ๊ณ ... ์ง์ง ๋ณต์กํ์์. ๊ทธ๋ฐ๋ฐ CSS Grid๊ฐ ๋ฑ์ฅํ๋ฉด์ ๋ชจ๋ ๊ฒ ๋ฌ๋ผ์ก์ด! ๐
CSS Grid๋ 2017๋ ์ ์ฃผ์ ๋ธ๋ผ์ฐ์ ๋ค์ด ๋์์ ์ง์ํ๊ธฐ ์์ํ 2์ฐจ์ ๋ ์ด์์ ์์คํ ์ด์ผ. ์ฌ๊ธฐ์ 2์ฐจ์์ด๋ผ๋ ๊ฒ ํต์ฌ์ธ๋ฐ, ํ(row)๊ณผ ์ด(column)์ ๋์์ ์ ์ดํ ์ ์๋ค๋ ๊ฑฐ์ง. Flexbox๊ฐ 1์ฐจ์(ํ ๋ฐฉํฅ)์ด๋ผ๋ฉด, Grid๋ ์์ ํ ๋ค๋ฅธ ๋ ๋ฒจ์ด์ผ.
๐ฏ Grid์ ํต์ฌ ๊ฐ๋ ์์ ์ ๋ณต
์, ์ด์ ๋ณธ๊ฒฉ์ ์ผ๋ก Grid์ ์ธ๊ณ๋ก ๋ค์ด๊ฐ ๋ณด์. Grid๋ฅผ ์ ๋๋ก ์ดํดํ๋ ค๋ฉด ๋ช ๊ฐ์ง ํต์ฌ ๊ฐ๋ ์ ์์์ผ ํด. ํ๋์ฉ ์น๊ตฌํํ ์ค๋ช ํ๋ฏ์ด ํ์ด๋ณผ๊ฒ! ๐
๐ฆ Grid Container์ Grid Item
Grid๋ ๊ธฐ๋ณธ์ ์ผ๋ก ๋ถ๋ชจ-์์ ๊ด๊ณ๋ก ์๋ํด. ๋ถ๋ชจ ์์์ display: grid๋ฅผ ์ ์ธํ๋ฉด, ๊ทธ ์์๊ฐ Grid Container๊ฐ ๋๊ณ , ์ง๊ณ ์์ ์์๋ค์ด ์๋์ผ๋ก Grid Item์ด ๋๋ ๊ฑฐ์ง.
.container {
display: grid;
/* ์ด์ ์ด ์์๋ Grid Container! */
}
/* ์ง๊ณ ์์๋ค์ ์๋์ผ๋ก Grid Item์ด ๋จ */
.container > .item {
/* Grid Item ์คํ์ผ */
}
display: grid๋ฅผ ์ ์ธํด์ผ ํด.
๐ Grid Line, Track, Cell, Area
Grid๋ฅผ ์ดํดํ๋ ๋ฐ ๊ฐ์ฅ ์ค์ํ ์ฉ์ด๋ค์ด์ผ. ์ด๊ฑฐ ๋ชจ๋ฅด๋ฉด Grid ๋ฌธ์ ์ฝ์ ๋ ์์ ํท๊ฐ๋ ค! ํ๋์ฉ ์ ๋ฆฌํด๋ณผ๊ฒ.
Grid Line ๐
Grid๋ฅผ ๊ตฌ์ฑํ๋ ๋ถํ ์ ์ด์ผ. 3๊ฐ์ ์ด์ด ์์ผ๋ฉด 4๊ฐ์ ์ธ๋ก ๋ผ์ธ์ด ์๊ธฐ๋ ๊ฑฐ์ง. ๋ผ์ธ์ 1๋ถํฐ ์์ํด์ ๋ฒํธ๊ฐ ๋งค๊ฒจ์ ธ. ์์๋ก๋ ์ ๊ทผํ ์ ์๋๋ฐ, -1์ ๋ง์ง๋ง ๋ผ์ธ์ ์๋ฏธํด!
Grid Track ๐ค๏ธ
๋ ๊ฐ์ ์ธ์ ํ Grid Line ์ฌ์ด์ ๊ณต๊ฐ์ด์ผ. ์ฝ๊ฒ ๋งํ๋ฉด ํ ๋๋ ์ด ํ๋๋ฅผ ์๋ฏธํ๋ ๊ฑฐ์ง. Row Track์ ๊ฐ๋ก์ค, Column Track์ ์ธ๋ก์ค!
Grid Cell ๐ฒ
Grid์ ์ต์ ๋จ์์ผ. ํ๊ณผ ์ด์ด ๊ต์ฐจํ๋ ํ๋์ ์นธ์ ๋งํด. ํ์ ํ ์นธ์ด๋ผ๊ณ ์๊ฐํ๋ฉด ๋ผ. ์ฌ๋ฌ Cell์ ํฉ์ณ์ ํ๋์ Item์ ๋ฐฐ์นํ ์๋ ์์ด!
Grid Area ๐
ํ๋ ์ด์์ Cell๋ก ์ด๋ฃจ์ด์ง ์ฌ๊ฐํ ์์ญ์ด์ผ. Grid Item์ด ์ฐจ์งํ๋ ๊ณต๊ฐ์ Area๋ผ๊ณ ๋ถ๋ฅด์ง. ์ด๋ฆ์ ๋ถ์ฌ์ ๊ด๋ฆฌํ ์๋ ์์ด!
๐ Grid Container ์์ฑ ๋ง์คํฐํ๊ธฐ
์, ์ด์ ์ค์ ์ด์ผ! Grid Container์ ์ ์ฉํ ์ ์๋ ์์ฑ๋ค์ ํ๋์ฉ ํํค์ณ๋ณด์. ์ด๊ฒ๋ค๋ง ์ ๋๋ก ์๋ฉด ์ฌ๋งํ ๋ ์ด์์์ ๋ค ๋ง๋ค ์ ์์ด! ๐ช
๐จ grid-template-columns / grid-template-rows
Grid์ ์ด๊ณผ ํ์ ํฌ๊ธฐ๋ฅผ ์ ์ํ๋ ๊ฐ์ฅ ๊ธฐ๋ณธ์ ์ธ ์์ฑ์ด์ผ. ์ฌ๊ธฐ์ ์ง์ง ๋ค์ํ ๋ฐฉ๋ฒ์ผ๋ก ํฌ๊ธฐ๋ฅผ ์ง์ ํ ์ ์์ด!
/* ๊ณ ์ ํฌ๊ธฐ๋ก 3๊ฐ์ ์ด */
.grid-1 {
display: grid;
grid-template-columns: 200px 200px 200px;
}
/* ๋น์จ๋ก ์ง์ (fr ๋จ์) */
.grid-2 {
display: grid;
grid-template-columns: 1fr 2fr 1fr;
/* 1:2:1 ๋น์จ๋ก ๊ณต๊ฐ ๋ถ๋ฐฐ */
}
/* ํผํฉ ์ฌ์ฉ */
.grid-3 {
display: grid;
grid-template-columns: 200px 1fr 2fr;
/* ์ฒซ ์ด์ 200px ๊ณ ์ , ๋๋จธ์ง๋ 1:2 ๋น์จ */
}
/* repeat() ํจ์๋ก ๋ฐ๋ณต */
.grid-4 {
display: grid;
grid-template-columns: repeat(3, 1fr);
/* 1fr์ 3๋ฒ ๋ฐ๋ณต = 1fr 1fr 1fr */
}
/* auto-fill๊ณผ minmax() ์กฐํฉ (๋ฐ์ํ์ ํต์ฌ!) */
.grid-5 {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
/* ์ต์ 250px, ๊ณต๊ฐ ์์ผ๋ฉด ์๋์ผ๋ก ๋์ด๋จ */
}
fr์ fraction(๋ถ์)์ ์ฝ์์ผ. Grid Container์ ๋จ์ ๊ณต๊ฐ์ ๋น์จ๋ก ๋๋ ๊ฐ์ง๋ ์ ์ฐํ ๋จ์์ง. ์๋ฅผ ๋ค์ด 1fr 2fr์ด๋ฉด ๋จ์ ๊ณต๊ฐ์ 1:2๋ก ๋๋ ๊ฐ์ง๋ ๊ฑฐ์ผ. ํฝ์
์ด๋ ํผ์ผํธ๋ณด๋ค ํจ์ฌ ์ง๊ด์ ์ด๊ณ ๊ฐ๋ ฅํด!
๐ฏ gap (grid-gap)
Grid Item ์ฌ์ด์ ๊ฐ๊ฒฉ์ ์ค์ ํ๋ ์์ฑ์ด์ผ. ์์ ์๋ grid-gap์ด์๋๋ฐ, ์ง๊ธ์ ๊ทธ๋ฅ gap์ผ๋ก ํต์ผ๋์ด. Flexbox์์๋ ์ธ ์ ์๊ฒ ๋ ๊ฑฐ์ง!
/* ํ๊ณผ ์ด ๊ฐ๊ฒฉ ๋์ผํ๊ฒ */
.grid {
display: grid;
gap: 20px;
}
/* ํ๊ณผ ์ด ๊ฐ๊ฒฉ ๋ค๋ฅด๊ฒ */
.grid {
display: grid;
gap: 20px 30px; /* row-gap column-gap */
}
/* ๊ฐ๋ณ ์ง์ ๋ ๊ฐ๋ฅ */
.grid {
display: grid;
row-gap: 20px;
column-gap: 30px;
}
๐ grid-template-areas
์ด๊ฑด ์ง์ง Grid์ ํฌ๋ฌ ๊ธฐ๋ฅ ์ค ํ๋์ผ! ๋ ์ด์์์ ์๊ฐ์ ์ผ๋ก ์ ์ํ ์ ์์ด์ ์ฝ๋๋ง ๋ด๋ ์ด๋ค ๋ ์ด์์์ธ์ง ๋ฐ๋ก ์ ์ ์์ง. ๐จ
.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;
}
/* ๊ฐ ์์ญ์ ์ด๋ฆ ํ ๋น */
.header { grid-area: header; }
.sidebar { grid-area: sidebar; }
.main { grid-area: main; }
.aside { grid-area: aside; }
.footer { grid-area: footer; }
์ ์ฝ๋๋ฅผ ๋ณด๋ฉด ๋ ์ด์์์ด ๋์ ๋ณด์ด์ง? ํค๋๊ฐ ์ ์ฒด ๋๋น๋ฅผ ์ฐจ์งํ๊ณ , ์ค๊ฐ์ ์ฌ์ด๋๋ฐ-๋ฉ์ธ-์ด์ฌ์ด๋๊ฐ ์๊ณ , ํธํฐ๊ฐ ๋ค์ ์ ์ฒด ๋๋น๋ฅผ ์ฐจ์งํ๋ ๊ตฌ์กฐ์ผ. ์ด๊ฒ ๋ฐ๋ก Grid์ ๋งค๋ ฅ์ด์ผ! ๐
๐ช justify-items / align-items
Grid Item๋ค์ Cell ์์์ ์ด๋ป๊ฒ ์ ๋ ฌํ ์ง ๊ฒฐ์ ํ๋ ์์ฑ์ด์ผ. Flexbox์ justify-content, align-items์ ๋น์ทํ๋ฐ, Grid์์๋ ๊ฐ Item์ ๊ฐ๋ณ์ ์ผ๋ก ์ ์ฉ๋ผ.
/* ๊ฐ๋ก ์ ๋ ฌ (justify-items) */
.grid {
display: grid;
justify-items: start; /* ์ผ์ชฝ ์ ๋ ฌ */
justify-items: end; /* ์ค๋ฅธ์ชฝ ์ ๋ ฌ */
justify-items: center; /* ๊ฐ์ด๋ฐ ์ ๋ ฌ */
justify-items: stretch; /* ๋๋ ค์ ์ฑ์ฐ๊ธฐ (๊ธฐ๋ณธ๊ฐ) */
}
/* ์ธ๋ก ์ ๋ ฌ (align-items) */
.grid {
display: grid;
align-items: start; /* ์์ชฝ ์ ๋ ฌ */
align-items: end; /* ์๋์ชฝ ์ ๋ ฌ */
align-items: center; /* ๊ฐ์ด๋ฐ ์ ๋ ฌ */
align-items: stretch; /* ๋๋ ค์ ์ฑ์ฐ๊ธฐ (๊ธฐ๋ณธ๊ฐ) */
}
/* ๋จ์ถ ์์ฑ */
.grid {
display: grid;
place-items: center; /* align-items์ justify-items๋ฅผ ๋์์ center */
}
๐ญ justify-content / align-content
์ด๊ฑด Grid ์ ์ฒด๋ฅผ Container ์์์ ์ด๋ป๊ฒ ๋ฐฐ์นํ ์ง ๊ฒฐ์ ํ๋ ์์ฑ์ด์ผ. Grid์ ์ ์ฒด ํฌ๊ธฐ๊ฐ Container๋ณด๋ค ์์ ๋ ์ ์ฉํ์ง!
.grid {
display: grid;
grid-template-columns: repeat(3, 200px);
width: 800px; /* Grid๋ณด๋ค Container๊ฐ ๋ ํผ */
justify-content: start; /* ์ผ์ชฝ ์ ๋ ฌ */
justify-content: end; /* ์ค๋ฅธ์ชฝ ์ ๋ ฌ */
justify-content: center; /* ๊ฐ์ด๋ฐ ์ ๋ ฌ */
justify-content: space-between; /* ์๋ ์ ๋ ฌ */
justify-content: space-around; /* ๊ท ๋ฑ ๋ถ๋ฐฐ */
justify-content: space-evenly; /* ์์ ๊ท ๋ฑ ๋ถ๋ฐฐ */
}
/* ๋จ์ถ ์์ฑ */
.grid {
place-content: center; /* ๊ฐ๋ก์ธ๋ก ๋ชจ๋ ๊ฐ์ด๋ฐ */
}
๐ฏ Grid Item ์์ฑ ์์ ์ ๋ณต
Container ์์ฑ๋งํผ์ด๋ ์ค์ํ ๊ฒ Item ์์ฑ์ด์ผ! ๊ฐ๋ณ Item์ ์ํ๋ ์์น์ ๋ฐฐ์นํ๊ณ , ํฌ๊ธฐ๋ฅผ ์กฐ์ ํ๋ ๋ฐฉ๋ฒ์ ์์๋ณด์. ๐จ
๐ grid-column / grid-row
Item์ด ์ด๋ ๋ผ์ธ๋ถํฐ ์ด๋ ๋ผ์ธ๊น์ง ์ฐจ์งํ ์ง ์ง์ ํ๋ ์์ฑ์ด์ผ. ์ด๊ฑธ๋ก Item์ ํฌ๊ธฐ์ ์์น๋ฅผ ์์ ์์ฌ๋ก ์กฐ์ ํ ์ ์์ด!
/* ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ */
.item {
grid-column-start: 1;
grid-column-end: 3;
/* 1๋ฒ ๋ผ์ธ๋ถํฐ 3๋ฒ ๋ผ์ธ๊น์ง (2์นธ ์ฐจ์ง) */
}
/* ๋จ์ถ ์์ฑ */
.item {
grid-column: 1 / 3;
/* start / end */
}
/* span ํค์๋ ์ฌ์ฉ */
.item {
grid-column: 1 / span 2;
/* 1๋ฒ ๋ผ์ธ๋ถํฐ 2์นธ ์ฐจ์ง */
grid-column: span 2;
/* ํ์ฌ ์์น์์ 2์นธ ์ฐจ์ง */
}
/* ์์ ์ธ๋ฑ์ค ํ์ฉ */
.item {
grid-column: 1 / -1;
/* ์ฒซ ๋ผ์ธ๋ถํฐ ๋ง์ง๋ง ๋ผ์ธ๊น์ง (์ ์ฒด ๋๋น) */
}
/* ํ๋ ๋์ผํ๊ฒ */
.item {
grid-row: 1 / 3;
/* 1๋ฒ ํ๋ถํฐ 3๋ฒ ํ๊น์ง */
}
span์ "๋ช ์นธ์ ์ฐจ์งํ ๊ฒ์ธ๊ฐ"๋ฅผ ์๋ฏธํด. grid-column: 2 / span 3์ด๋ฉด 2๋ฒ ๋ผ์ธ๋ถํฐ ์์ํด์ 3์นธ์ ์ฐจ์งํ๋ ๊ฑฐ์ผ. ์ฆ, 2๋ฒ๋ถํฐ 5๋ฒ ๋ผ์ธ๊น์ง ์ฐจ์งํ๊ฒ ๋๋ ๊ฑฐ์ง!
๐จ grid-area
์ด ์์ฑ์ ๋ ๊ฐ์ง ์ฉ๋๋ก ์ฌ์ฉ๋ผ. ์ฒซ ๋ฒ์งธ๋ grid-template-areas์์ ์ ์ํ ์์ญ ์ด๋ฆ์ ํ ๋นํ๋ ๊ฑฐ๊ณ , ๋ ๋ฒ์งธ๋ grid-column๊ณผ grid-row๋ฅผ ํ ๋ฒ์ ์ง์ ํ๋ ๋จ์ถ ์์ฑ์ผ๋ก ์ฐ๋ ๊ฑฐ์ผ!
/* ์ฉ๋ 1: ์์ญ ์ด๋ฆ ํ ๋น */
.header {
grid-area: header;
}
/* ์ฉ๋ 2: ์์น ๋จ์ถ ์ง์ */
.item {
grid-area: 1 / 2 / 3 / 4;
/* row-start / column-start / row-end / column-end */
}
/* ์ ์ฝ๋๋ ์๋์ ๋์ผ */
.item {
grid-row: 1 / 3;
grid-column: 2 / 4;
}
๐ฏ justify-self / align-self
Container์ justify-items, align-items๋ฅผ ๊ฐ๋ณ Item์์ ์ฌ์ ์ํ ์ ์๋ ์์ฑ์ด์ผ. ํน์ Item๋ง ๋ค๋ฅด๊ฒ ์ ๋ ฌํ๊ณ ์ถ์ ๋ ์ฌ์ฉํด!
.item {
justify-self: start; /* ์ด Item๋ง ์ผ์ชฝ ์ ๋ ฌ */
align-self: end; /* ์ด Item๋ง ์๋์ชฝ ์ ๋ ฌ */
}
/* ๋จ์ถ ์์ฑ */
.item {
place-self: center; /* ๊ฐ๋ก์ธ๋ก ๋ชจ๋ ๊ฐ์ด๋ฐ */
place-self: start end; /* align-self start, justify-self end */
}
๐ order
Flexbox์๋ ์๋ ์์ฑ์ธ๋ฐ, Grid์์๋ ์ฌ์ฉํ ์ ์์ด! Item์ ์๊ฐ์ ์์๋ฅผ ๋ณ๊ฒฝํ ์ ์์ง. HTML ๊ตฌ์กฐ๋ ๊ทธ๋๋ก ๋๊ณ ๋ณด์ด๋ ์์๋ง ๋ฐ๊ฟ ์ ์์ด์ ๋ฐ์ํ ๋์์ธ์ ์ ์ฉํด!
.item-1 { order: 2; }
.item-2 { order: 1; }
.item-3 { order: 3; }
/* item-2๊ฐ ๋จผ์ ๋ณด์ด๊ณ , ๊ทธ ๋ค์ item-1, ๋ง์ง๋ง์ item-3 */
/* ๊ธฐ๋ณธ๊ฐ์ 0์ด๊ณ , ์ซ์๊ฐ ์์์๋ก ์์ ๋ฐฐ์น๋จ */
๐ฅ ์ค์ ๋ ์ด์์ ํจํด ๋ชจ์
์ด๋ก ์ ์ด์ ์ถฉ๋ถํด! ์ค์ ๋ก ๋ง์ด ์ฌ์ฉ๋๋ ๋ ์ด์์ ํจํด๋ค์ ํ๋์ฉ ๋ง๋ค์ด๋ณด์. ์ด๊ฒ๋ค๋ง ์์๋ ๋๋ถ๋ถ์ ์น์ฌ์ดํธ ๋ ์ด์์์ ๊ฑฐ๋ฌํด! ๐ช
๐จ ํจํด 1: ๊ธฐ๋ณธ ๋ธ๋ก๊ทธ ๋ ์ด์์
ํค๋, ์ฌ์ด๋๋ฐ, ๋ฉ์ธ ์ฝํ ์ธ , ํธํฐ๋ก ๊ตฌ์ฑ๋ ๊ฐ์ฅ ํด๋์ํ ๋ ์ด์์์ด์ผ. Grid๋ฅผ ์ฒ์ ๋ฐฐ์ธ ๋ ๊ผญ ๋ง๋ค์ด๋ด์ผ ํ๋ ๋ ์ด์์์ด์ง!
<div class="blog-layout">
<header class="header">Header</header>
<aside class="sidebar">Sidebar</aside>
<main class="main">Main Content</main>
<footer class="footer">Footer</footer>
</div>
<style>
.blog-layout {
display: grid;
grid-template-columns: 250px 1fr;
grid-template-rows: auto 1fr auto;
grid-template-areas:
"header header"
"sidebar main"
"footer footer";
min-height: 100vh;
gap: 20px;
}
.header { grid-area: header; background: #74b9ff; padding: 20px; }
.sidebar { grid-area: sidebar; background: #fdcb6e; padding: 20px; }
.main { grid-area: main; background: #55efc4; padding: 20px; }
.footer { grid-area: footer; background: #ff7675; padding: 20px; }
/* ๋ฐ์ํ: ๋ชจ๋ฐ์ผ์์๋ 1์ด๋ก */
@media (max-width: 768px) {
.blog-layout {
grid-template-columns: 1fr;
grid-template-areas:
"header"
"main"
"sidebar"
"footer";
}
}
</style>
๐ช ํจํด 2: ์นด๋ ๊ทธ๋ฆฌ๋ (์๋ ๋ฐ์ํ)
์ด๊ฑด ์ง์ง Grid์ ํฌ๋ฌ ๊ธฐ๋ฅ์ด์ผ! ๋ฏธ๋์ด ์ฟผ๋ฆฌ ์์ด๋ ์๋์ผ๋ก ๋ฐ์ํ์ด ๋๋ ๋ง๋ฒ ๊ฐ์ ๋ ์ด์์์ด์ง. ๐ช
<div class="card-grid">
<div class="card">Card 1</div>
<div class="card">Card 2</div>
<div class="card">Card 3</div>
<div class="card">Card 4</div>
<div class="card">Card 5</div>
<div class="card">Card 6</div>
</div>
<style>
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 24px;
padding: 20px;
}
.card {
background: white;
border-radius: 12px;
padding: 24px;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
min-height: 200px;
}
</style>
auto-fit: ๋จ๋ ๊ณต๊ฐ์ด ์์ผ๋ฉด ๊ธฐ์กด ์์ดํ ๋ค์ ๋๋ ค์ ์ฑ์. ๋น ํธ๋์ ์ ๊ฑฐํด.
๋๋ถ๋ถ์ ๊ฒฝ์ฐ
auto-fit์ด ๋ ์์ฐ์ค๋ฌ์ด ๊ฒฐ๊ณผ๋ฅผ ๋ง๋ค์ด!
๐ฏ ํจํด 3: ์ฑ๋ฐฐ ๋ ์ด์์ (Holy Grail)
์น ๋์์ธ์ ์ ์ค์ ์ธ ๋ ์ด์์์ด์ผ! ํค๋, ํธํฐ, ๋ฉ์ธ ์ฝํ ์ธ , ์์ชฝ ์ฌ์ด๋๋ฐ๋ก ๊ตฌ์ฑ๋ ๋ ์ด์์์ธ๋ฐ, ์์ ์๋ ๋ง๋ค๊ธฐ ์ ๋ง ์ด๋ ค์ ์ด. ํ์ง๋ง Grid๋ก๋ ์์ ์ฃฝ ๋จน๊ธฐ์ง! ๐
<div class="holy-grail">
<header class="header">Header</header>
<nav class="nav">Navigation</nav>
<main class="content">Main Content</main>
<aside class="ads">Advertisements</aside>
<footer class="footer">Footer</footer>
</div>
<style>
.holy-grail {
display: grid;
grid-template-columns: 200px 1fr 200px;
grid-template-rows: auto 1fr auto;
grid-template-areas:
"header header header"
"nav content ads"
"footer footer footer";
min-height: 100vh;
gap: 16px;
}
.header { grid-area: header; }
.nav { grid-area: nav; }
.content { grid-area: content; }
.ads { grid-area: ads; }
.footer { grid-area: footer; }
/* ํ๋ธ๋ฆฟ: ๊ด๊ณ ๋ฅผ ์๋๋ก */
@media (max-width: 1024px) {
.holy-grail {
grid-template-columns: 200px 1fr;
grid-template-areas:
"header header"
"nav content"
"ads ads"
"footer footer";
}
}
/* ๋ชจ๋ฐ์ผ: 1์ด๋ก */
@media (max-width: 768px) {
.holy-grail {
grid-template-columns: 1fr;
grid-template-areas:
"header"
"nav"
"content"
"ads"
"footer";
}
}
</style>
๐ฑ ํจํด 4: ๋งค๊ฑฐ์ง ๋ ์ด์์
๋ด์ค ์ฌ์ดํธ๋ ๋งค๊ฑฐ์ง์์ ์์ฃผ ๋ณด๋ ๋ ์ด์์์ด์ผ. ๋ฉ์ธ ๊ธฐ์ฌ๊ฐ ํฌ๊ฒ ๋์ค๊ณ , ์์ ๊ธฐ์ฌ๋ค์ด ์ฃผ๋ณ์ ์ฑ์ฐ๋ ํํ์ง. Grid์ ์ง๊ฐ๋ฅผ ๋ณด์ฌ์ฃผ๋ ๋ ์ด์์์ด์ผ! ๐ฐ
<div class="magazine">
<article class="featured">Featured Article</article>
<article class="article-1">Article 1</article>
<article class="article-2">Article 2</article>
<article class="article-3">Article 3</article>
<article class="article-4">Article 4</article>
</div>
<style>
.magazine {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(3, 200px);
gap: 16px;
}
.featured {
grid-column: 1 / 3;
grid-row: 1 / 3;
background: #6c5ce7;
color: white;
}
.article-1 {
grid-column: 3 / 5;
grid-row: 1 / 2;
background: #74b9ff;
}
.article-2 {
grid-column: 3 / 4;
grid-row: 2 / 3;
background: #fdcb6e;
}
.article-3 {
grid-column: 4 / 5;
grid-row: 2 / 3;
background: #55efc4;
}
.article-4 {
grid-column: 1 / 5;
grid-row: 3 / 4;
background: #fab1a0;
}
/* ๋ชจ๋ฐ์ผ: ์์ฐจ์ ๋ฐฐ์น */
@media (max-width: 768px) {
.magazine {
grid-template-columns: 1fr;
grid-template-rows: auto;
}
.featured,
.article-1,
.article-2,
.article-3,
.article-4 {
grid-column: 1;
grid-row: auto;
}
}
</style>
๐จ ํจํด 5: ๋์๋ณด๋ ๋ ์ด์์
๊ด๋ฆฌ์ ํ์ด์ง๋ ๋ฐ์ดํฐ ๋์๋ณด๋์์ ๋ง์ด ์ฐ๋ ๋ ์ด์์์ด์ผ. ๋ค์ํ ํฌ๊ธฐ์ ์์ ฏ๋ค์ ํจ์จ์ ์ผ๋ก ๋ฐฐ์นํ ์ ์์ด!
<div class="dashboard">
<div class="widget stats">Statistics</div>
<div class="widget chart">Chart</div>
<div class="widget users">Users</div>
<div class="widget activity">Activity</div>
<div class="widget notifications">Notifications</div>
</div>
<style>
.dashboard {
display: grid;
grid-template-columns: repeat(6, 1fr);
grid-auto-rows: 150px;
gap: 20px;
padding: 20px;
}
.widget {
background: white;
border-radius: 12px;
padding: 20px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.stats {
grid-column: span 2;
grid-row: span 1;
}
.chart {
grid-column: span 4;
grid-row: span 2;
}
.users {
grid-column: span 2;
grid-row: span 1;
}
.activity {
grid-column: span 3;
grid-row: span 1;
}
.notifications {
grid-column: span 3;
grid-row: span 1;
}
/* ํ๋ธ๋ฆฟ */
@media (max-width: 1024px) {
.dashboard {
grid-template-columns: repeat(4, 1fr);
}
.stats,
.users {
grid-column: span 2;
}
.chart,
.activity,
.notifications {
grid-column: span 4;
}
}
/* ๋ชจ๋ฐ์ผ */
@media (max-width: 768px) {
.dashboard {
grid-template-columns: 1fr;
}
.widget {
grid-column: span 1 !important;
}
}
</style>
๐ฏ ๊ณ ๊ธ Grid ํ ํฌ๋
๊ธฐ๋ณธ์ ๋ง์คํฐํ์ง? ์ด์ ์ข ๋ ๊ณ ๊ธ ํ ํฌ๋๋ค์ ์์๋ณด์. ์ด๊ฒ๋ค์ ์๋ฉด ์ง์ง Grid ๋ง์คํฐ๊ฐ ๋ ์ ์์ด! ๐
๐ Implicit Grid vs Explicit Grid
Grid์๋ ๋ช ์์ ๊ทธ๋ฆฌ๋์ ์์์ ๊ทธ๋ฆฌ๋๋ผ๋ ๊ฐ๋ ์ด ์์ด. ์ด๊ฑธ ์ดํดํ๋ฉด Grid๊ฐ ์ด๋ป๊ฒ ๋์ํ๋์ง ์๋ฒฝํ๊ฒ ์ ์ ์์ง!
Implicit Grid (์์์ ): ์ ์ํ ๊ทธ๋ฆฌ๋๋ฅผ ๋ฒ์ด๋๋ ์์ดํ ์ด ์์ ๋ ์๋์ผ๋ก ์์ฑ๋๋ ๊ทธ๋ฆฌ๋
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: 100px 100px;
/* 3์ด 2ํ์ ๋ช
์์ ์ผ๋ก ์ ์ */
grid-auto-rows: 150px;
/* ์์์ ์ผ๋ก ์์ฑ๋๋ ํ์ ํฌ๊ธฐ */
grid-auto-flow: row;
/* ์์ดํ
์ด ์ด๋ป๊ฒ ๋ฐฐ์น๋ ์ง (row | column | dense) */
}
/* ์์ดํ
์ด 6๊ฐ๋ฅผ ๋์ด๊ฐ๋ฉด ์๋์ผ๋ก ์ ํ์ด ์์ฑ๋จ */
/* ์ด๋ grid-auto-rows์ ์ ์ํ 150px ๋์ด๊ฐ ์ ์ฉ๋จ */
๐จ grid-auto-flow: dense
์ด๊ฑด ์ง์ง ์ ๊ธฐํ ๊ธฐ๋ฅ์ด์ผ! Grid๊ฐ ๋น ๊ณต๊ฐ์ ์๋์ผ๋ก ์ฑ์์ฃผ๋ ์๊ณ ๋ฆฌ์ฆ์ด์ง. ํนํ ํฌ๊ธฐ๊ฐ ๋ค๋ฅธ ์์ดํ ๋ค์ ๋ฐฐ์นํ ๋ ์ ์ฉํด!
.masonry-like {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
grid-auto-rows: 100px;
gap: 16px;
grid-auto-flow: dense;
/* ๋น ๊ณต๊ฐ์ ์ฑ์ฐ๋ ์๊ณ ๋ฆฌ์ฆ ํ์ฑํ */
}
.item-large {
grid-column: span 2;
grid-row: span 2;
}
.item-tall {
grid-row: span 2;
}
.item-wide {
grid-column: span 2;
}
/* dense ์๊ณ ๋ฆฌ์ฆ์ด ๋น ๊ณต๊ฐ์ ์์ ์์ดํ
๋ค์ ์๋์ผ๋ก ๋ฐฐ์น */
๐ minmax()์ fit-content()
Grid์ ์ ์ฐ์ฑ์ ๊ทน๋ํํ๋ ํจ์๋ค์ด์ผ. ์ต์/์ต๋ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๊ฑฐ๋, ์ฝํ ์ธ ์ ๋ง์ถฐ ํฌ๊ธฐ๋ฅผ ์กฐ์ ํ ์ ์์ด!
/* minmax(): ์ต์๊ฐ๊ณผ ์ต๋๊ฐ ์ง์ */
.grid {
display: grid;
grid-template-columns:
minmax(200px, 300px) /* ์ต์ 200px, ์ต๋ 300px */
minmax(300px, 1fr) /* ์ต์ 300px, ๋จ์ ๊ณต๊ฐ ์ฐจ์ง */
minmax(150px, 200px);
}
/* fit-content(): ์ฝํ
์ธ ํฌ๊ธฐ์ ๋ง์ถค (์ต๋๊ฐ ์ ํ) */
.grid {
display: grid;
grid-template-columns:
fit-content(200px) /* ์ฝํ
์ธ ํฌ๊ธฐ, ์ต๋ 200px */
1fr
fit-content(300px);
}
/* ์ค์ฉ์ ์ธ ์์: ์ฌ์ด๋๋ฐ */
.layout {
display: grid;
grid-template-columns:
minmax(200px, 250px) /* ์ฌ์ด๋๋ฐ: ์ต์ 200px */
minmax(300px, 1fr) /* ๋ฉ์ธ: ์ต์ 300px, ๋๋จธ์ง ์ฐจ์ง */
minmax(200px, 300px); /* ๊ด๊ณ : ์ต์ 200px, ์ต๋ 300px */
}
๐ฏ Named Lines (์ด๋ฆ ์๋ ๋ผ์ธ)
Grid Line์ ์ด๋ฆ์ ๋ถ์ฌ์ ๋ ์ง๊ด์ ์ผ๋ก ๊ด๋ฆฌํ ์ ์์ด. ๋ณต์กํ ๋ ์ด์์์์ ํนํ ์ ์ฉํ์ง!
.grid {
display: grid;
grid-template-columns:
[sidebar-start] 250px
[sidebar-end content-start] 1fr
[content-end aside-start] 200px
[aside-end];
grid-template-rows:
[header-start] auto
[header-end main-start] 1fr
[main-end footer-start] auto
[footer-end];
}
/* ์ด๋ฆ์ผ๋ก ์์น ์ง์ */
.header {
grid-column: sidebar-start / aside-end;
grid-row: header-start / header-end;
}
.sidebar {
grid-column: sidebar-start / sidebar-end;
grid-row: main-start / main-end;
}
.content {
grid-column: content-start / content-end;
grid-row: main-start / main-end;
}
span ํค์๋์ ํจ๊ป ์ฌ์ฉํ ์ ์์ง. ์๋ฅผ ๋ค์ด grid-column: content / span 2๋ 'content'๋ผ๋ ์ด๋ฆ์ ๋ผ์ธ๋ถํฐ 2์นธ์ ์ฐจ์งํด!
๐ฅ Subgrid (์๋ธ๊ทธ๋ฆฌ๋)
CSS Grid Level 2์์ ์ถ๊ฐ๋ ๊ธฐ๋ฅ์ด์ผ! Grid Item ๋ด๋ถ์์ ๋ถ๋ชจ Grid์ ๋ผ์ธ์ ์์๋ฐ์ ์ ์์ด. ์์ง ๋ธ๋ผ์ฐ์ ์ง์์ด ์๋ฒฝํ์ง ์์ง๋ง, ์ ๋ง ๊ฐ๋ ฅํ ๊ธฐ๋ฅ์ด์ผ!
.parent-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 20px;
}
.child-grid {
grid-column: span 2;
display: grid;
grid-template-columns: subgrid;
/* ๋ถ๋ชจ์ ์ด ๊ตฌ์กฐ๋ฅผ ์์๋ฐ์ */
gap: 10px;
}
/* ์์ Grid์ ์์ดํ
๋ค์ด ๋ถ๋ชจ Grid์ ๋ผ์ธ์ ์ ๋ ฌ๋จ */
/* ๋ณต์กํ ์ค์ฒฉ ๋ ์ด์์์์ ์ ๋ ฌ์ ์ ์งํ๊ธฐ ์ฌ์์ง */
โ Safari: ์์ ์ง์
โ ๏ธ Chrome/Edge: ์ง์ (๋ฒ์ 117+)
โ IE: ๋ฏธ์ง์ (๋น์ฐํ์ง๋ง...)
ํ๋ก๋์ ์์ ์ฌ์ฉํ๋ ค๋ฉด
@supports๋ก ๊ธฐ๋ฅ ๊ฐ์ง๋ฅผ ํด์ผ ํด!
๐จ Grid์ Flexbox ์กฐํฉํ๊ธฐ
๋ง์ ์ฌ๋๋ค์ด Grid์ Flexbox ์ค ๋ญ ์จ์ผ ํ๋ ๊ณ ๋ฏผํ๋๋ฐ, ์ ๋ต์ ๋ ๋ค ์ฐ๋ ๊ฑฐ์ผ! ๊ฐ์ ์ฅ์ ์ด ๋ค๋ฅด๋๊น ์ํฉ์ ๋ง๊ฒ ์กฐํฉํด์ ์ฐ๋ฉด ์ต๊ณ ์ ๊ฒฐ๊ณผ๋ฅผ ๋ง๋ค ์ ์์ด! ๐ฏ
๐ค ์ธ์ ๋ญ ์จ์ผ ํ ๊น?
Grid๋ฅผ ์ฐ๋ฉด ์ข์ ๋ ๐
โข 2์ฐจ์ ๋ ์ด์์ (ํ๊ณผ ์ด ๋์ ์ ์ด)
โข ์ ์ฒด ํ์ด์ง ๋ ์ด์์
โข ๋ณต์กํ ๋ฐฐ์น๊ฐ ํ์ํ ๊ฒฝ์ฐ
โข ์์ดํ
๊ฐ ์ ๋ ฌ์ด ์ค์ํ ๊ฒฝ์ฐ
โข ๋ฐ์ํ ๊ทธ๋ฆฌ๋ ์์คํ
Flexbox๋ฅผ ์ฐ๋ฉด ์ข์ ๋ ๐ช
โข 1์ฐจ์ ๋ ์ด์์ (ํ ๋ฐฉํฅ๋ง)
โข ๋ค๋น๊ฒ์ด์
๋ฉ๋ด
โข ์นด๋ ๋ด๋ถ ์ฝํ
์ธ ๋ฐฐ์น
โข ๋์ ํฌ๊ธฐ์ ์์ดํ
๋ค
โข ๊ฐ๋จํ ์ ๋ ฌ
๐ฏ ์ค์ ์กฐํฉ ์์
/* Grid๋ก ์ ์ฒด ๋ ์ด์์, Flexbox๋ก ๋ด๋ถ ์ฝํ
์ธ */
.page-layout {
display: grid;
grid-template-columns: 250px 1fr;
grid-template-rows: auto 1fr auto;
grid-template-areas:
"header header"
"sidebar main"
"footer footer";
min-height: 100vh;
}
/* ํค๋ ๋ด๋ถ๋ Flexbox๋ก */
.header {
grid-area: header;
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px;
}
.header-nav {
display: flex;
gap: 20px;
list-style: none;
}
/* ๋ฉ์ธ ์ฝํ
์ธ ๋ Grid๋ก ์นด๋ ๋ฐฐ์น */
.main {
grid-area: main;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 24px;
padding: 20px;
}
/* ๊ฐ ์นด๋ ๋ด๋ถ๋ Flexbox๋ก */
.card {
display: flex;
flex-direction: column;
background: white;
border-radius: 12px;
overflow: hidden;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px;
}
.card-body {
flex: 1;
padding: 16px;
}
.card-footer {
display: flex;
justify-content: flex-end;
gap: 12px;
padding: 16px;
border-top: 1px solid #e0e0e0;
}
๐ฑ ๋ฐ์ํ Grid ๋ง์คํฐํ๊ธฐ
Grid์ ์ง์ง ๊ฐ๋ ฅํจ์ ๋ฐ์ํ ๋์์ธ์์ ๋ํ๋! ๋ฏธ๋์ด ์ฟผ๋ฆฌ์ ์กฐํฉํ๋ฉด ์ ๋ง ์ ์ฐํ ๋ ์ด์์์ ๋ง๋ค ์ ์์ด. ๐จ
๐ฏ ๋ชจ๋ฐ์ผ ํผ์คํธ ์ ๊ทผ๋ฒ
์์ฆ์ ๋ชจ๋ฐ์ผ ํผ์คํธ๊ฐ ๋์ธ์ง! ์์ ํ๋ฉด๋ถํฐ ์์ํด์ ์ ์ ํฐ ํ๋ฉด์ผ๋ก ํ์ฅํ๋ ๋ฐฉ์์ด์ผ.
/* ๊ธฐ๋ณธ: ๋ชจ๋ฐ์ผ (1์ด) */
.responsive-grid {
display: grid;
grid-template-columns: 1fr;
gap: 16px;
padding: 16px;
}
/* ํ๋ธ๋ฆฟ: 2์ด */
@media (min-width: 768px) {
.responsive-grid {
grid-template-columns: repeat(2, 1fr);
gap: 24px;
padding: 24px;
}
}
/* ๋ฐ์คํฌํฑ: 3์ด */
@media (min-width: 1024px) {
.responsive-grid {
grid-template-columns: repeat(3, 1fr);
gap: 32px;
padding: 32px;
}
}
/* ๋ํ ํ๋ฉด: 4์ด */
@media (min-width: 1440px) {
.responsive-grid {
grid-template-columns: repeat(4, 1fr);
gap: 40px;
padding: 40px;
}
}
๐ฅ ๋ฏธ๋์ด ์ฟผ๋ฆฌ ์๋ ๋ฐ์ํ
Grid์ auto-fit๊ณผ minmax()๋ฅผ ์กฐํฉํ๋ฉด ๋ฏธ๋์ด ์ฟผ๋ฆฌ ์์ด๋ ์๋ฒฝํ ๋ฐ์ํ์ ๋ง๋ค ์ ์์ด! ์ด๊ฒ ์ง์ง Grid์ ๋ง๋ฒ์ด์ผ! โจ
/* ๋ง๋ฒ์ ํ ์ค */
.auto-responsive {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 24px;
}
/* ์ด๊ฒ ๋! ํ๋ฉด ํฌ๊ธฐ์ ๋ฐ๋ผ ์๋์ผ๋ก ์ด ๊ฐ์๊ฐ ์กฐ์ ๋จ */
/* 280px๋ณด๋ค ์์์ง๋ฉด ์๋์ผ๋ก ์ค๋ฐ๊ฟ */
/* ์ข ๋ ์ธ๋ฐํ ์ ์ด */
.advanced-responsive {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
gap: clamp(16px, 3vw, 32px);
/* gap๋ ๋ฐ์ํ์ผ๋ก! */
}
/* Container Query ํ์ฉ (์ต์ ๊ธฐ๋ฅ) */
.container {
container-type: inline-size;
}
.grid-in-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
}
@container (min-width: 600px) {
.grid-in-container {
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
}
๐ grid-template-areas๋ก ๋ฐ์ํ ๋ง๋ค๊ธฐ
์ด ๋ฐฉ๋ฒ์ ์ ๋ง ์ง๊ด์ ์ด์ผ! ํ๋ฉด ํฌ๊ธฐ๋ณ๋ก ๋ ์ด์์ ๊ตฌ์กฐ๋ฅผ ์๊ฐ์ ์ผ๋ก ์ฌ์ ์ํ ์ ์์ด.
/* ๋ชจ๋ฐ์ผ: ์ธ๋ก ๋ฐฐ์น */
.layout {
display: grid;
grid-template-columns: 1fr;
grid-template-areas:
"header"
"nav"
"main"
"aside"
"footer";
gap: 16px;
}
/* ํ๋ธ๋ฆฟ: 2์ด ๊ตฌ์กฐ */
@media (min-width: 768px) {
.layout {
grid-template-columns: 200px 1fr;
grid-template-areas:
"header header"
"nav nav"
"aside main"
"footer footer";
}
}
/* ๋ฐ์คํฌํฑ: 3์ด ๊ตฌ์กฐ */
@media (min-width: 1024px) {
.layout {
grid-template-columns: 200px 1fr 250px;
grid-template-areas:
"header header header"
"nav main aside"
"footer footer footer";
}
}
/* ๊ฐ ์์ญ์ ํ ๋ฒ๋ง ์ ์ */
.header { grid-area: header; }
.nav { grid-area: nav; }
.main { grid-area: main; }
.aside { grid-area: aside; }
.footer { grid-area: footer; }
๐ Grid ๋๋ฒ๊น ๊ณผ ๊ฐ๋ฐ์ ๋๊ตฌ
Grid ๋ ์ด์์์ ๋ง๋ค๋ค ๋ณด๋ฉด ๊ฐ๋ ๋จธ๋ฆฌ๊ฐ ์ํ ๋๊ฐ ์์ด. ๊ทธ๋ด ๋ ์ฌ์ฉํ๋ ๋๋ฒ๊น ํ๋ค์ ์๋ ค์ค๊ฒ! ๐
๐ ๏ธ ๋ธ๋ผ์ฐ์ ๊ฐ๋ฐ์ ๋๊ตฌ ํ์ฉ
์ต์ ๋ธ๋ผ์ฐ์ ๋ค์ Grid ๋๋ฒ๊น ์ ์ํ ๊ฐ๋ ฅํ ๋๊ตฌ๋ฅผ ์ ๊ณตํด!
2. 'grid' ๋ฐฐ์ง ํด๋ฆญํ๋ฉด Grid ์ค๋ฒ๋ ์ด ํ์
3. Layout ํญ์์ Grid ์ค์ ํ์ธ ๋ฐ ์กฐ์
4. ๋ผ์ธ ๋ฒํธ, ์์ญ ์ด๋ฆ, gap ๋ฑ์ด ์๊ฐ์ ์ผ๋ก ํ์๋จ
๐ฆ Firefox DevTools:
1. Inspector์์ Grid Container ์ ํ
2. Layout ํญ์ Grid ์น์ ํ์ธ
3. 'Display line numbers' ์ฒดํฌ๋ฐ์ค๋ก ๋ผ์ธ ๋ฒํธ ํ์
4. 'Display area names' ์ฒดํฌ๋ฐ์ค๋ก ์์ญ ์ด๋ฆ ํ์
5. Firefox๊ฐ Grid ๋๋ฒ๊น ๋๊ตฌ๋ ๊ฐ์ฅ ๊ฐ๋ ฅํด!
๐จ ์๊ฐ์ ๋๋ฒ๊น CSS
๊ฐ๋ฐ ์ค์ Grid ๊ตฌ์กฐ๋ฅผ ์ฝ๊ฒ ํ์ ํ๋ ค๋ฉด ์ด๋ฐ CSS๋ฅผ ์ถ๊ฐํด๋ด!
/* ๊ฐ๋ฐ ์ค ๋๋ฒ๊น
์ฉ ์คํ์ผ */
.debug-grid {
/* Grid ๋ผ์ธ ์๊ฐํ */
background-image:
repeating-linear-gradient(
0deg,
rgba(255, 0, 0, 0.1) 0px,
rgba(255, 0, 0, 0.1) 1px,
transparent 1px,
transparent 100px
),
repeating-linear-gradient(
90deg,
rgba(0, 0, 255, 0.1) 0px,
rgba(0, 0, 255, 0.1) 1px,
transparent 1px,
transparent 100px
);
}
/* Grid Item์ ํ
๋๋ฆฌ ์ถ๊ฐ */
.debug-grid > * {
outline: 2px solid rgba(255, 0, 0, 0.3);
background: rgba(0, 255, 0, 0.05);
}
/* ๊ฐ Item์ ๋ฒํธ ํ์ */
.debug-grid > *::before {
content: counter(item);
counter-increment: item;
position: absolute;
top: 5px;
left: 5px;
background: red;
color: white;
padding: 2px 6px;
border-radius: 3px;
font-size: 12px;
font-weight: bold;
}
.debug-grid {
counter-reset: item;
}
๐จ ์์ฃผ ํ๋ ์ค์๋ค
grid-column, grid-row ๋ฑ์ Grid Container์ ์ง๊ณ ์์์๋ง ์ ์ฉ๋ผ!โ ์ค์ 2: fr ๋จ์์ ๊ณ ์ ํฌ๊ธฐ ํผ์ฉ ์ ๊ณ์ฐ ์ฐฉ์ค
grid-template-columns: 200px 1fr 1fr์์ 1fr์ (์ ์ฒด - 200px) / 2๊ฐ ์๋๋ผ (์ ์ฒด - 200px - gap)์ ๋๋ ๊ฑฐ์ผ!โ ์ค์ 3: gap์ margin์ผ๋ก ์ฐฉ๊ฐ
gap์ Item ์ฌ์ด์๋ง ์ ์ฉ๋ผ. Container ๊ฐ์ฅ์๋ฆฌ์๋ ์ ์ฉ ์ ๋ผ!
โ ์ค์ 4: grid-area ์์ ํท๊ฐ๋ฆผ
grid-area: row-start / column-start / row-end / column-end ์์์ผ. ํท๊ฐ๋ฆฌ์ง ๋ง!โ ์ค์ 5: minmax()์์ ์ต์๊ฐ์ด ์ต๋๊ฐ๋ณด๋ค ํผ
minmax(500px, 300px) ์ด๋ฐ ๊ฑด ์ ๋ผ! ์ต์๊ฐ์ด ํญ์ ์ต๋๊ฐ๋ณด๋ค ์์์ผ ํด.
โก Grid ์ฑ๋ฅ ์ต์ ํ
Grid๋ ๊ฐ๋ ฅํ์ง๋ง, ์๋ชป ์ฌ์ฉํ๋ฉด ์ฑ๋ฅ ๋ฌธ์ ๊ฐ ์๊ธธ ์ ์์ด. ์ต์ ํ ํ๋ค์ ์์๋ณด์! ๐
๐ฏ ์ฑ๋ฅ์ ์ํ ๋ฒ ์คํธ ํ๋ํฐ์ค
/* โ
์ข์ ์: ๊ฐ๋จํ๊ณ ๋ช
ํํ Grid */
.good-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
}
/* โ ๋์ ์: ๊ณผ๋ํ๊ฒ ๋ณต์กํ Grid */
.bad-grid {
display: grid;
grid-template-columns:
minmax(100px, 1fr)
minmax(150px, 2fr)
minmax(100px, 1fr)
minmax(200px, 3fr)
minmax(100px, 1fr);
grid-template-rows:
repeat(20, minmax(100px, auto));
/* ๋๋ฌด ๋ณต์กํ๋ฉด ๊ณ์ฐ ๋น์ฉ์ด ์ปค์ง */
}
/* โ
์ข์ ์: will-change๋ก ์ ๋๋ฉ์ด์
์ต์ ํ */
.animated-grid-item {
will-change: transform;
transition: transform 0.3s ease;
}
.animated-grid-item:hover {
transform: scale(1.05);
}
/* โ
์ข์ ์: contain ์์ฑ์ผ๋ก ๋ ์ด์์ ๊ฒฉ๋ฆฌ */
.grid-item {
contain: layout style paint;
/* ๋ธ๋ผ์ฐ์ ์๊ฒ ์ด ์์๊ฐ ๋
๋ฆฝ์ ์์ ์๋ฆผ */
}
๐ ๋๋์ Grid Item ๋ค๋ฃจ๊ธฐ
์๋ฐฑ ๊ฐ์ Item์ ๋ค๋ฃฐ ๋๋ ํน๋ณํ ์ฃผ์๊ฐ ํ์ํด!
/* ๊ฐ์ ์คํฌ๋กค๋ง ๊ณ ๋ ค */
/* ํ๋ฉด์ ๋ณด์ด๋ Item๋ง ๋ ๋๋ง */
/* CSS๋ก ํ ์ ์๋ ์ต์ ํ */
.large-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 16px;
/* ํ๋์จ์ด ๊ฐ์ ํ์ฑํ */
transform: translateZ(0);
/* ๋ ์ด์์ ๊ณ์ฐ ์ต์ ํ */
contain: layout;
}
.large-grid-item {
/* ๊ฐ๋ณ Item๋ ์ต์ ํ */
contain: layout style paint;
/* ๋ถํ์ํ ๋ฆฌํ๋ก์ฐ ๋ฐฉ์ง */
will-change: auto;
}
/* JavaScript์ ํจ๊ป ์ฌ์ฉํ๋ Intersection Observer */
/* ํ๋ฉด์ ๋ณด์ด๋ Item๋ง ์คํ์ผ ์ ์ฉ */
๐จ Grid์ ์ ๋๋ฉ์ด์
Grid ๋ ์ด์์์ ๋ถ๋๋ฌ์ด ์ ๋๋ฉ์ด์ ์ ์ถ๊ฐํ๋ฉด ์ฌ์ฉ์ ๊ฒฝํ์ด ํจ์ฌ ์ข์์ ธ! ๋ช ๊ฐ์ง ๋ฉ์ง ํ ํฌ๋์ ์๋ ค์ค๊ฒ. โจ
๐ญ Grid Item ์ ๋๋ฉ์ด์
/* ํธ๋ฒ ์ ํ๋ ํจ๊ณผ */
.grid-item {
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.grid-item:hover {
transform: scale(1.05);
box-shadow: 0 8px 24px rgba(0,0,0,0.15);
z-index: 1;
}
/* ์์ฐจ์ ๋ฑ์ฅ ์ ๋๋ฉ์ด์
*/
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.grid-item {
animation: fadeInUp 0.6s ease backwards;
}
/* nth-child๋ก ๋๋ ์ด ์ฃผ๊ธฐ */
.grid-item:nth-child(1) { animation-delay: 0.1s; }
.grid-item:nth-child(2) { animation-delay: 0.2s; }
.grid-item:nth-child(3) { animation-delay: 0.3s; }
/* ๋๋ calc() ์ฌ์ฉ */
.grid-item {
animation-delay: calc(var(--item-index) * 0.1s);
}
/* Grid ๊ตฌ์กฐ ๋ณ๊ฒฝ ์ ๋๋ฉ์ด์
*/
.responsive-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
transition: gap 0.3s ease;
}
.responsive-grid:hover {
gap: 30px;
}
๐ช ๋ ์ด์์ ์ ํ ์ ๋๋ฉ์ด์
Grid ๋ ์ด์์ ์์ฒด๋ฅผ ๋ถ๋๋ฝ๊ฒ ์ ํํ๋ ๊ฑด ์กฐ๊ธ ๊น๋ค๋ก์. ํ์ง๋ง ๋ช ๊ฐ์ง ํธ๋ฆญ์ด ์์ด!
/* View Transitions API ํ์ฉ (์ต์ ๊ธฐ๋ฅ) */
@media (prefers-reduced-motion: no-preference) {
::view-transition-old(root),
::view-transition-new(root) {
animation-duration: 0.5s;
}
}
/* JavaScript๋ก ๋ ์ด์์ ์ ํ */
document.startViewTransition(() => {
grid.classList.toggle('layout-2');
});
/* FLIP ๊ธฐ๋ฒ (First, Last, Invert, Play) */
/* JavaScript๋ก ๊ตฌํ */
const items = document.querySelectorAll('.grid-item');
// First: ์ด๊ธฐ ์์น ์ ์ฅ
const first = Array.from(items).map(item =>
item.getBoundingClientRect()
);
// ๋ ์ด์์ ๋ณ๊ฒฝ
grid.classList.toggle('new-layout');
// Last: ์ต์ข
์์น ๊ณ์ฐ
const last = Array.from(items).map(item =>
item.getBoundingClientRect()
);
// Invert: ์ฐจ์ด ๊ณ์ฐ ๋ฐ ์ ์ฉ
items.forEach((item, index) => {
const deltaX = first[index].left - last[index].left;
const deltaY = first[index].top - last[index].top;
item.style.transform = `translate(${deltaX}px, ${deltaY}px)`;
item.style.transition = 'transform 0s';
});
// Play: ์ ๋๋ฉ์ด์
์คํ
requestAnimationFrame(() => {
items.forEach(item => {
item.style.transform = '';
item.style.transition = 'transform 0.5s ease';
});
});
๐ ์ค๋ฌด์์ Grid ํ์ฉํ๊ธฐ
์ด๋ก ์ ์ถฉ๋ถํ ๋ฐฐ์ ์ผ๋, ์ด์ ์ค๋ฌด์์ ์ด๋ป๊ฒ ํ์ฉํ๋์ง ์์๋ณด์! ์ค์ ํ๋ก์ ํธ์์ ์์ฃผ ๋ง์ฃผ์น๋ ์ํฉ๋ค์ด์ผ. ๐ผ
๐ฏ ์ด์ปค๋จธ์ค ์ํ ๊ทธ๋ฆฌ๋
<div class="product-grid">
<div class="product-card">
<div class="product-image">...</div>
<div class="product-info">
<h3 class="product-title">์ํ๋ช
</h3>
<p class="product-price">โฉ29,900</p>
<div class="product-rating">โญโญโญโญโญ</div>
</div>
<button class="add-to-cart">์ฅ๋ฐ๊ตฌ๋</button>
</div>
<!-- ๋ ๋ง์ ์ํ๋ค... -->
</div>
<style>
.product-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 24px;
padding: 24px;
}
.product-card {
display: grid;
grid-template-rows: 300px auto auto;
background: white;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.product-card:hover {
transform: translateY(-4px);
box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.product-image {
width: 100%;
height: 100%;
object-fit: cover;
background: #f5f5f5;
}
.product-info {
padding: 16px;
display: flex;
flex-direction: column;
gap: 8px;
}
.product-title {
font-size: 16px;
font-weight: 600;
margin: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.product-price {
font-size: 20px;
font-weight: 700;
color: #e74c3c;
margin: 0;
}
.add-to-cart {
margin: 0 16px 16px;
padding: 12px;
background: #3498db;
color: white;
border: none;
border-radius: 8px;
font-weight: 600;
cursor: pointer;
transition: background 0.3s ease;
}
.add-to-cart:hover {
background: #2980b9;
}
/* ํํฐ ์ฌ์ด๋๋ฐ์ ํจ๊ป ์ฌ์ฉ */
.shop-layout {
display: grid;
grid-template-columns: 250px 1fr;
gap: 24px;
padding: 24px;
}
@media (max-width: 768px) {
.shop-layout {
grid-template-columns: 1fr;
}
.product-grid {
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
gap: 16px;
}
}
</style>
๐ฐ ๋ด์ค/๋ธ๋ก๊ทธ ๋ ์ด์์
.news-layout {
display: grid;
grid-template-columns: repeat(12, 1fr);
gap: 24px;
padding: 24px;
}
/* ๋ฉ์ธ ๊ธฐ์ฌ */
.featured-article {
grid-column: 1 / 9;
grid-row: 1 / 3;
position: relative;
border-radius: 16px;
overflow: hidden;
}
/* ์๋ธ ๊ธฐ์ฌ๋ค */
.sub-article-1 {
grid-column: 9 / 13;
grid-row: 1 / 2;
}
.sub-article-2 {
grid-column: 9 / 13;
grid-row: 2 / 3;
}
/* ์ผ๋ฐ ๊ธฐ์ฌ๋ค */
.article {
grid-column: span 4;
}
/* ํ๋ธ๋ฆฟ */
@media (max-width: 1024px) {
.featured-article {
grid-column: 1 / 13;
grid-row: 1 / 2;
}
.sub-article-1,
.sub-article-2 {
grid-column: span 6;
grid-row: auto;
}
.article {
grid-column: span 6;
}
}
/* ๋ชจ๋ฐ์ผ */
@media (max-width: 768px) {
.news-layout {
grid-template-columns: 1fr;
}
.featured-article,
.sub-article-1,
.sub-article-2,
.article {
grid-column: 1;
}
}
๐จ ํฌํธํด๋ฆฌ์ค ๊ฐค๋ฌ๋ฆฌ
/* Masonry ์คํ์ผ ๊ฐค๋ฌ๋ฆฌ */
.portfolio-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
grid-auto-rows: 20px;
gap: 16px;
}
.portfolio-item {
border-radius: 12px;
overflow: hidden;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
/* ๊ฐ ์์ดํ
์ ๋์ด๋ฅผ ๋ค๋ฅด๊ฒ */
.portfolio-item:nth-child(1) { grid-row: span 10; }
.portfolio-item:nth-child(2) { grid-row: span 15; }
.portfolio-item:nth-child(3) { grid-row: span 12; }
.portfolio-item:nth-child(4) { grid-row: span 18; }
.portfolio-item:nth-child(5) { grid-row: span 14; }
/* ๋๋ JavaScript๋ก ๋์ ๊ณ์ฐ */
/*
const items = document.querySelectorAll('.portfolio-item');
items.forEach(item => {
const height = item.querySelector('img').offsetHeight;
const span = Math.ceil(height / 20);
item.style.gridRowEnd = `span ${span}`;
});
*/
/* ํํฐ ๊ธฐ๋ฅ๊ณผ ํจ๊ป */
.portfolio-grid[data-filter="web"] .portfolio-item:not([data-category="web"]) {
display: none;
}
/* ์ ๋๋ฉ์ด์
์ถ๊ฐ */
.portfolio-item {
opacity: 0;
animation: fadeIn 0.6s ease forwards;
}
@keyframes fadeIn {
to {
opacity: 1;
}
}
๐ Grid ํ์ต ๋ฆฌ์์ค์ ๋๊ตฌ
Grid๋ฅผ ๋ ๊น์ด ๊ณต๋ถํ๊ณ ์ถ๋ค๋ฉด ์ด๋ฐ ๋ฆฌ์์ค๋ค์ ํ์ฉํด๋ด! ๐
๐ ์ถ์ฒ ํ์ต ์๋ฃ
๊ณต์ ๋ฌธ์ ๐
MDN Web Docs: ๊ฐ์ฅ ์ ํํ๊ณ ์์ธํ CSS Grid ๋ฌธ์
CSS-Tricks Complete Guide: ์ค์ฉ์ ์ธ ์์ ๊ฐ ๊ฐ๋ํ ๊ฐ์ด๋
W3C Specification: ํ์ค ๋ช
์ธ์ (๊ณ ๊ธ ์ฌ์ฉ์์ฉ)
์ธํฐ๋ํฐ๋ธ ํ์ต ๐ฎ
Grid Garden: ๊ฒ์์ผ๋ก ๋ฐฐ์ฐ๋ CSS Grid
CSS Grid Generator: ์๊ฐ์ ์ผ๋ก Grid ์์ฑ
Griddy: Grid ๋ ์ด์์ ํ๋ ์ด๊ทธ๋ผ์ด๋
์ ์ฉํ ๋๊ตฌ ๐ ๏ธ
Firefox DevTools: ์ต๊ณ ์ Grid ๋๋ฒ๊น
๋๊ตฌ
Chrome DevTools: Grid ์ค๋ฒ๋ ์ด ๊ธฐ๋ฅ
VS Code Extensions: CSS Grid ์๋์์ฑ
์ปค๋ฎค๋ํฐ ๐ฅ
CodePen: Grid ์์ ํ์
Stack Overflow: ๋ฌธ์ ํด๊ฒฐ
์ฌ๋ฅ๋ท: ์น๊ฐ๋ฐ ์ ๋ฌธ๊ฐ์ ์๋ด
๐ฎ Grid์ ๋ฏธ๋
CSS Grid๋ ๊ณ์ ์งํํ๊ณ ์์ด! ์์ผ๋ก ์ด๋ค ๊ธฐ๋ฅ๋ค์ด ์ถ๊ฐ๋ ์ง ์ดํด๋ณด์. ๐
๐ ๊ณง ์ฌ ์๋ก์ด ๊ธฐ๋ฅ๋ค
/* Masonry Layout (์คํ์ ) */
.masonry {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
grid-template-rows: masonry;
/* Pinterest ์คํ์ผ ๋ ์ด์์์ ๋ค์ดํฐ๋ธ๋ก! */
}
/* Subgrid ํ์ฅ */
.nested-grid {
display: grid;
grid-template-columns: subgrid;
grid-template-rows: subgrid;
/* ํ๊ณผ ์ด ๋ชจ๋ ๋ถ๋ชจ Grid ์์ */
}
/* Container Query Units */
.responsive-item {
font-size: clamp(1rem, 5cqw, 2rem);
/* Container Query Width ๋จ์ */
padding: 2cqh;
/* Container Query Height ๋จ์ */
}
/* Grid Level 3 ๊ธฐ๋ฅ๋ค */
.advanced-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
/* ๋ ์ค๋งํธํ ๋ฐ์ํ */
align-content: space-evenly;
/* ๋ ๋ง์ ์ ๋ ฌ ์ต์
*/
}
๐ ๋ธ๋ผ์ฐ์ ์ง์ ํํฉ
| ๊ธฐ๋ฅ | Chrome | Firefox | Safari | Edge |
|---|---|---|---|---|
| ๊ธฐ๋ณธ Grid | โ 57+ | โ 52+ | โ 10.1+ | โ 16+ |
| gap ์์ฑ | โ 66+ | โ 61+ | โ 12+ | โ 79+ |
| Subgrid | โ 117+ | โ 71+ | โ 16+ | โ 117+ |
| Container Queries | โ 105+ | โ 110+ | โ 16+ | โ 105+ |
| Masonry | โ ๏ธ ์คํ์ | โ ๏ธ ์คํ์ | โ | โ ๏ธ ์คํ์ |
@supports ๊ท์น์ผ๋ก ๊ธฐ๋ฅ ์ง์ ์ฌ๋ถ๋ฅผ ํ์ธํ๋ ๊ฒ ์ข์!@supports (display: grid) {
/* Grid ์ง์ ์ ์คํ์ผ */
}
๐ช ์ค์ ํ๋ก์ ํธ ์ฒดํฌ๋ฆฌ์คํธ
Grid๋ฅผ ์ค์ ํ๋ก์ ํธ์ ์ ์ฉํ ๋ ํ์ธํด์ผ ํ ์ฌํญ๋ค์ ์ ๋ฆฌํด๋ดค์ด! โ
๐ฏ ๊ธฐํ ๋จ๊ณ
โ ๋ ์ด์์ ๊ตฌ์กฐ ์ค์ผ์นํ๊ธฐ
โ ๋ฐ์ํ ๋ธ๋ ์ดํฌํฌ์ธํธ ์ ์ํ๊ธฐ
โ Grid vs Flexbox ์ ํ ๊ธฐ์ค ์ ํ๊ธฐ
โ ๋ธ๋ผ์ฐ์ ์ง์ ๋ฒ์ ํ์ธํ๊ธฐ
โ ํด๋ฐฑ(fallback) ์ ๋ต ์๋ฆฝํ๊ธฐ
๐จ ๋์์ธ ๋จ๊ณ
โ Grid ์ด/ํ ๊ฐ์ ๊ฒฐ์ ํ๊ธฐ
โ gap ํฌ๊ธฐ ์ ์ํ๊ธฐ
โ ๋ฐ์ํ ๋ ์ด์์ ๋ณํ ๊ณํํ๊ธฐ
โ ์ ๋๋ฉ์ด์
ํ์ ์ฌ๋ถ ๊ฒํ ํ๊ธฐ
โ ์ ๊ทผ์ฑ ๊ณ ๋ ค์ฌํญ ์ฒดํฌํ๊ธฐ
๐ป ๊ฐ๋ฐ ๋จ๊ณ
โ ์๋งจํฑ HTML ๊ตฌ์กฐ ์์ฑํ๊ธฐ
โ Grid Container ์ค์ ํ๊ธฐ
โ Grid Item ๋ฐฐ์นํ๊ธฐ
โ ๋ฐ์ํ ๋ฏธ๋์ด ์ฟผ๋ฆฌ ์์ฑํ๊ธฐ
โ ๋ธ๋ผ์ฐ์ ํ
์คํธํ๊ธฐ
โ ์ฑ๋ฅ ์ต์ ํํ๊ธฐ
๐งช ํ ์คํธ ๋จ๊ณ
โ ๋ค์ํ ํ๋ฉด ํฌ๊ธฐ์์ ํ
์คํธ
โ ๋ค์ํ ๋ธ๋ผ์ฐ์ ์์ ํ
์คํธ
โ ์ฝํ
์ธ ์ ๋ณํ ํ
์คํธ
โ ์ ๊ทผ์ฑ ํ
์คํธ (์คํฌ๋ฆฐ ๋ฆฌ๋)
โ ์ฑ๋ฅ ์ธก์ (Lighthouse)
โ ํฌ๋ก์ค ๋ธ๋ผ์ฐ์ ์ด์ ํด๊ฒฐ
๐ฌ ๋ง๋ฌด๋ฆฌํ๋ฉฐ
์, ์ฌ๊ธฐ๊น์ง ์๋ค๋! ์ ๋ง ์๊ณ ํ์ด! ๐ CSS Grid๋ ์ฒ์์ ๋ณต์กํด ๋ณด์ด์ง๋ง, ํ ๋ฒ ์ต์ํด์ง๋ฉด ์ ๋ง ๊ฐ๋ ฅํ ๋๊ตฌ๊ฐ ๋ผ. ์ด์ ๋๋ Grid ๋ง์คํฐ์ ๊ธธ์ ํ ๋ฐ์ง ๋ค๊ฐ์ ๊ฑฐ์ผ!
๐ ํต์ฌ ์์ฝ
1. Grid๋ 2์ฐจ์ ๋ ์ด์์ ์์คํ
ํ๊ณผ ์ด์ ๋์์ ์ ์ดํ ์ ์์ด ๋ณต์กํ ๋ ์ด์์๋ ์ฝ๊ฒ ๋ง๋ค ์ ์์ด!
2. Container์ Item ์์ฑ์ ๊ตฌ๋ถํ์
์ด๋ค ์์ฑ์ ์ด๋์ ์จ์ผ ํ๋์ง ๋ช
ํํ ์ดํดํ๋ ๊ฒ ์ค์ํด!
3. ๋ฐ์ํ์ auto-fit + minmax()๋ก
๋ฏธ๋์ด ์ฟผ๋ฆฌ ์์ด๋ ์๋ ๋ฐ์ํ ๋ ์ด์์์ ๋ง๋ค ์ ์์ด!
4. Grid์ Flexbox๋ฅผ ํจ๊ป ์ฌ์ฉํ์
์ ์ฒด ๋ ์ด์์์ Grid, ์ปดํฌ๋ํธ ๋ด๋ถ๋ Flexbox!
5. ๋ธ๋ผ์ฐ์ ๊ฐ๋ฐ์ ๋๊ตฌ๋ฅผ ํ์ฉํ์
Grid ๋๋ฒ๊น
์ ์๊ฐ์ ๋๊ตฌ๊ฐ ํ์์ผ!
CSS Grid๋ ๊ณ์ ์งํํ๊ณ ์์ด. Subgrid, Masonry, Container Queries ๊ฐ์ ์๋ก์ด ๊ธฐ๋ฅ๋ค์ด ์ถ๊ฐ๋๋ฉด์ ๋์ฑ ๊ฐ๋ ฅํด์ง๊ณ ์์ง. ์์ผ๋ก๋ ๊ณ์ ๋ฐฐ์ฐ๊ณ ์คํํด๋ณด๋ฉด์ Grid์ ๊ฐ๋ฅ์ฑ์ ํํํด๋ด! ๐
ํน์ Grid๋ฅผ ์ฌ์ฉํ๋ค๊ฐ ๋งํ๋ ๋ถ๋ถ์ด ์๊ฑฐ๋, ๋ณต์กํ ๋ ์ด์์ ๊ตฌํ์ ๋์์ด ํ์ํ๋ค๋ฉด ์ฌ๋ฅ๋ท์ ์น๊ฐ๋ฐ ์ ๋ฌธ๊ฐ๋ค์๊ฒ ๋ฌธ์ํด๋ด. ์ค๋ฌด ๊ฒฝํ์ด ํ๋ถํ ๊ฐ๋ฐ์๋ค์ด ๋์ ํ๋ก์ ํธ๋ฅผ ์ฑ๊ณต์ผ๋ก ์ด๋์ด์ค ๊ฑฐ์ผ! ๐ช
์, ์ด์ ์ง์ ์ฝ๋๋ฅผ ์์ฑํด๋ณด๋ฉด์ Grid์ ๋งค๋ ฅ์ ๋๊ปด๋ด. ์ฒ์์ ์ด๋ ค์ธ ์ ์์ง๋ง, ๊ณ์ ์ฐ์ตํ๋ค ๋ณด๋ฉด ์ด๋์ Grid ์์ด๋ ๋ ์ด์์์ ๋ง๋ค ์ ์๊ฒ ๋ ๊ฑฐ์ผ! ๐
Happy Coding! ๐จโจ
๐ ์ด ๊ธ์ด ๋์์ด ๋์๋์?
CSS Grid๋ฅผ ํ์ฉํ ์น๊ฐ๋ฐ ํ๋ก์ ํธ๊ฐ ํ์ํ๋ค๋ฉด,
์ฌ๋ฅ๋ท์์ ์ ๋ฌธ๊ฐ์ ํจ๊ปํ์ธ์!
์น๊ฐ๋ฐ ํ๋ก ํธ์๋ CSS Grid ๋ฐ์ํ ๋์์ธ ๋ ์ด์์
๊ด๋ จ ํค์๋
๋๊ธ ์์ฑ
์ด ๊ธ์ ๋ํ ์ฌ๋ฌ๋ถ์ ์๊ฐ์ ๋ค๋ ค์ฃผ์ธ์
๋ก๊ทธ์ธ์ด ํ์ํฉ๋๋ค
๋๊ธ์ ์์ฑํ๋ ค๋ฉด ๋จผ์ ๋ก๊ทธ์ธํด์ฃผ์ธ์.
๋๊ธ 0
์ง์์ธ์ ์ฒ - ์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
- ์ ์๊ถ ๋ฐ ์์ ๊ถ: ๋ณธ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ๋ ์ AI ๊ธฐ์ ๋ก ์์ฑ๋์์ผ๋ฉฐ, ๋ํ๋ฏผ๊ตญ ์ ์๊ถ๋ฒ ๋ฐ ๊ตญ์ ์ ์๊ถ ํ์ฝ์ ์ํด ๋ณดํธ๋ฉ๋๋ค.
- AI ์์ฑ ์ปจํ ์ธ ์ ๋ฒ์ ์ง์: ๋ณธ AI ์์ฑ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ์ง์ ์ฐฝ์๋ฌผ๋ก ์ธ์ ๋๋ฉฐ, ๊ด๋ จ ๋ฒ๊ท์ ๋ฐ๋ผ ์ ์๊ถ ๋ณดํธ๋ฅผ ๋ฐ์ต๋๋ค.
- ์ฌ์ฉ ์ ํ: ์ฌ๋ฅ๋ท์ ๋ช ์์ ์๋ฉด ๋์ ์์ด ๋ณธ ์ปจํ ์ธ ๋ฅผ ๋ณต์ , ์์ , ๋ฐฐํฌ, ๋๋ ์์ ์ ์ผ๋ก ํ์ฉํ๋ ํ์๋ ์๊ฒฉํ ๊ธ์ง๋ฉ๋๋ค.
- ๋ฐ์ดํฐ ์์ง ๊ธ์ง: ๋ณธ ์ปจํ ์ธ ์ ๋ํ ๋ฌด๋จ ์คํฌ๋ํ, ํฌ๋กค๋ง, ๋ฐ ์๋ํ๋ ๋ฐ์ดํฐ ์์ง์ ๋ฒ์ ์ ์ฌ์ ๋์์ด ๋ฉ๋๋ค.
- AI ํ์ต ์ ํ: ์ฌ๋ฅ๋ท์ AI ์์ฑ ์ปจํ ์ธ ๋ฅผ ํ AI ๋ชจ๋ธ ํ์ต์ ๋ฌด๋จ ์ฌ์ฉํ๋ ํ์๋ ๊ธ์ง๋๋ฉฐ, ์ด๋ ์ง์ ์ฌ์ฐ๊ถ ์นจํด๋ก ๊ฐ์ฃผ๋ฉ๋๋ค.
์์ง ๋๊ธ์ด ์์ต๋๋ค.