CHAPTER 69
CSS Flex Items
Learn how individual flex items can grow, shrink and change their basis inside a flex container.
01. What is CSS Flex Items?
Flex item properties control individual children inside a flex container.
flex-grow controls how much an item can grow.
flex-shrink controls how much an item can shrink.
flex-basis defines the initial size.
02. Syntax
.item {
flex-grow: 1;
flex-shrink: 1;
flex-basis: 200px;
}
03. Example
CSS / HTML Example
AIFA Coding Lab
<!DOCTYPE html>
<html>
<head>
<style>
.container {
display: flex;
gap: 15px;
}
.item {
flex: 1;
padding: 30px;
background: #dbeafe;
}
.large {
flex: 2;
}
</style>
</head>
<body>
<div class="container">
<div class="item">One</div>
<div class="item large">Two</div>
<div class="item">Three</div>
</div>
</body>
</html>
04. Important Points
✓
flex-grow controls extra space distribution.
✓
flex-shrink controls shrinking.
✓
flex-basis controls initial size.
✓
The flex shorthand combines these properties.
05. Common Mistakes
⚠
Using incorrect flex values.
⚠
Not understanding available space.
⚠
Creating items that become too small on mobile.
06. Real World Use
Flex item properties are useful for cards, dashboard columns, pricing plans and responsive layouts.
Ready to Practice? 🚀
Open the AIFA CSS Editor and practice this chapter live.
Try It Yourself →
Practice Exercise
Create Unequal Flex Cards
Create three cards and make the middle card twice as wide using flex.