📐
Flexbox

Flex Container Properties

justify-content, align-items, flex-direction
💡 Container properties poore group ko control karte hain — jaise ek teacher class ko instructions deta hai "line mein khade ho jao" (flex-direction), "beech mein aa jao" (justify-content), "height match karo" (align-items).

flex-direction — row (default, horizontal) ya column (vertical). justify-content — main axis ke along distribution (flex-start, center, space-between, space-around). align-items — cross axis ke along alignment (stretch, center, flex-start, flex-end). flex-wrap — items ek line mein force fit karo (nowrap, default) ya multiple lines mein wrap hone do (wrap).

.container {
  display: flex;
  flex-direction: row;         /* row (default) ya column */
  justify-content: space-between;  /* items ke beech max spacing */
  align-items: center;           /* cross-axis centering */
  flex-wrap: wrap;                /* zaroorat par naye line mein wrap ho */
  gap: 20px;                      /* items ke beech consistent spacing */
}
📐
Container properties poore group ko control karte hain — jaise ek teacher class ko instructions deta hai "line mein khade ho jao" (flex-direction), "beech mein aa jao" (justify-content), "height match karo" (align-items).
1 / 2
⚡ Quick Recap
  • flex-direction = row/column, main axis decide karta hai
  • justify-content = main axis distribution, align-items = cross axis
  • gap = items ke beech spacing, modern aur clean
Is page mein (2 subtopics)

align-items single LINE ke items ko cross-axis align karta hai. align-content MULTIPLE lines (jab flex-wrap: wrap ho aur content wrap ho jaaye) ko cross-axis mein distribute karta hai — sirf tab effect dikhta hai jab multiple lines hon.

.container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;      /* har line ke andar items center align */
  align-content: space-between;   /* MULTIPLE lines ke beech spacing */
  height: 400px;
}
💡Tip: align-content sirf tab kaam karta hai jab container mein extra vertical space ho AUR multiple lines ho (flex-wrap: wrap ke saath) — single-line flex containers mein koi visible effect nahi.

flex-direction: row-reverse/column-reverse items ka VISUAL order reverse kar deta hai (HTML order same rehta hai) — kabhi-kabhi RTL languages ya specific design needs ke liye useful.

.container {
  display: flex;
  flex-direction: row-reverse;
  /* HTML order: A, B, C
     Visual order: C, B, A */
}
⚠️Common Mistake: row-reverse/column-reverse accessibility ke liye caution ke saath use karo — screen readers HTML (DOM) order follow karte hain, visual reverse hone se "reading order" aur "visual order" mismatch ho sakta hai, confusing ho sakta hai.