Grid vs Flex: Which One Should You Use? ๐Ÿค”

์ž‘์„ฑ์ž

์นดํ…Œ๊ณ ๋ฆฌ:

โ† ํ”ผ๋“œ๋กœ
DEV Community ยท Narasimma Radhakrishnan ยท 2026-09-11 ๊ฐœ๋ฐœ(SW)

Narasimma Radhakrishnan

As a beginner in CSS, I was confused between Flexbox and Grid. Both are powerful layout tools, but they solve different problems.

Flexbox = One Direction

Use Flexbox when you want to arrange items in a row or a column.

Example: Navigation bar, buttons, or a row of cards.
.container {
display: flex;
justify-content: center;
align-items: center;
}

Grid = Two Dimensions

Use Grid when you need both rows and columns.

Example: Image gallery, dashboard, or product layout.

.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}

css #webdev #beginners #frontend

Top comments (1)

Code of Conduct โ€ข Report abuse

์›๋ฌธ์—์„œ ๊ณ„์† โ†—

์ถ”์ถœ ๋ณธ๋ฌธ ยท ์ถœ์ฒ˜: dev.to ยท https://dev.to/narasimma/grid-vs-flex-which-one-should-you-use-124f