|
Getting your Trinity Audio player ready... |
Have you ever built a flexbox layout and felt like your elements were fighting for space? ๐ค Maybe one div stubbornly sticks to its original size while others awkwardly shrink or overflow? If youโve been there, itโs time to introduce yourself to the powerful little CSS property: **flex-grow**.
Letโs break it down like weโre chatting over chai (or coffee โ๏ธ).
๐ค What is flex-grow?
In short, flex-grow tells a flex item how much space it should take up compared to its siblings inside a flex container.
Imagine you and two friends are splitting a pizza ๐. If you say โIโm really hungry,โ and theyโre like โmeh,โ then you should get a bigger slice, right? Thatโs flex-grow in action.
.item {
flex-grow: 1;
}
It tells the browser: โHey, Iโm okay expanding if thereโs room.โ
๐ฆ The Default Behavior
By default, flex-grow is set to 0, which means: โDonโt grow me, I like my size as it is.โ
.item {
flex-grow: 0; /* Default */
}
All items will stay at their intrinsic size, no matter how much space is left.
๐ฅ Real-Life Example
Letโs say you have three flex items:
<div class="container">
<div class="box a">A</div>
<div class="box b">B</div>
<div class="box c">C</div>
</div>
.container {
display: flex;
}
.a {
flex-grow: 1;
}
.b {
flex-grow: 2;
}
.c {
flex-grow: 1;
}
This means:
.bwill take twice as much space as.aand.c.- Total grow units = 1 + 2 + 1 = 4
- So space distribution:
.a= 25%.b= 50%.c= 25%
Isnโt that neat? ๐
See the Pen Untitled by Arsalan malik (@Arsalan-malik-the-builder) on CodePen.
๐ก Why Use flex-grow?
โ
Make responsive layouts
โ
Avoid hardcoded widths
โ
Let elements adapt to space
โ
Say goodbye to complicated media queries (in many cases)
โ ๏ธ Gotchas to Watch Out For
๐ธ flex-grow only works inside a flex container
๐ธ Works relative to siblings โ not absolute pixels
๐ธ Combine it wisely with flex-shrink and flex-basis for full control
๐ฏ TL;DR (Too Lazy? Donโt Worry ๐)
flex-grow = how much an item should stretch to fill space.
0 โ donโt grow
1+ โ grow proportionally
๐ฌ Whatโs Your Flex Game Like?
Do you use flex-grow in your layouts? Or still leaning on floats and margins? Share your favorite tricks or common flex mistakes below ๐
Letโs make CSS less scaryโone property at a time.
Originally published on Makemychance.com ๐

Arsalan Malik is a passionate Software Engineer and the Founder of Makemychance.com. A proud CDAC-qualified developer, Arsalan specializes in full-stack web development, with expertise in technologies like Node.js, PHP, WordPress, React, and modern CSS frameworks.
He actively shares his knowledge and insights with the developer community on platforms like Dev.to and engages with professionals worldwide through LinkedIn.
Arsalan believes in building real-world projects that not only solve problems but also educate and empower users. His mission is to make technology simple, accessible, and impactful for everyone.
Join us on dev community

