CSS
🎯 CSS justify-content Property
The justify-content CSS property is used in Flexbox to align items along the main (horizontal) axis.
It controls how items are distributed when there is extra space inside a flex container.
-
📌 Important Note
- The main axis depends on flex-direction.
- row → horizontal axis (left to right)
- column → vertical axis (top to bottom)
🔹 justify-content Values
1️⃣ flex-start
Items are aligned at the start of the container.
2️⃣ flex-end
Items are aligned at the end of the container.
3️⃣ center
Items are centered inside the container.
4️⃣ space-between
Space is distributed evenly between items.
5️⃣ space-around
Space is distributed around items equally.
6️⃣ initial
Resets the property to default (usually flex-start).
🧩 Example Usage
.container {
display: flex;
justify-content: space-between;
width: 500px;
}
.item {
width: 50px;
height: 50px;
}
In this example, items are evenly distributed across the container width.
-
✔️ Quick Summary
- flex-start → Items align at start
- flex-end → Items align at end
- center → Items centered
- space-between → Space between items
- space-around → Space around items
