Hackforge Academy

Category: javascript

css flexbox layouts alignment wrapping

Published on 30 Sep 2026

Explanation

Flexbox is a one-dimensional CSS layout system used to arrange elements in a row or column.

Code:

.container {
  display: flex;
}

.item {
  padding: 20px;
}

Explanation

flex-direction controls whether flex items are arranged horizontally or vertically.

Code:

.container {
  display: flex;
  flex-direction: row;
}

/* row | row-reverse | column | column-reverse */

Explanation

justify-content controls alignment along the main axis.

Code:

.container {
  display: flex;
  justify-content: space-between;
}

Explanation

align-items controls alignment along the cross axis.

Code:

.container {
  display: flex;
  align-items: center;
  height: 200px;
}

Explanation

flex-wrap allows items to move onto multiple lines when there is not enough horizontal space.

Code:

.container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.item {
  width: 200px;
}

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community