🌐 Detecting your location…
📢 Advertisement — Configure AdSense in Appearance → Customize → AdSense Settings

सीएसएस फ्लेक्सबॉक्स संपूर्ण गाइड 2026: लेआउट, पैटर्न और वास्तविक उदाहरण

⏱️2 min read  ·  432 words

सीएसएस फ्लेक्सबॉक्स अभी भी 2026 में यूआई घटकों के लिए सबसे महत्वपूर्ण लेआउट टूल है। जबकि सीएसएस ग्रिड दो-आयामी लेआउट को संभालता है, फ्लेक्सबॉक्स एक-आयामी संरेखण, उत्तरदायी नेविगेशन बार, कार्ड लेआउट और केंद्रित तत्वों में उत्कृष्टता प्राप्त करता है। यह संपूर्ण मार्गदर्शिका प्रत्येक संपत्ति को दृश्य उदाहरणों के साथ कवर करती है।

फ्लेक्स कंटेनर गुण

.container {
  display: flex;          /* or inline-flex */
  flex-direction: row;    /* row | row-reverse | column | column-reverse */
  flex-wrap: nowrap;      /* nowrap | wrap | wrap-reverse */
  flex-flow: row nowrap;  /* shorthand: flex-direction + flex-wrap */

  /* Main axis alignment (row = horizontal, column = vertical) */
  justify-content: flex-start;   /* flex-start | flex-end | center | space-between | space-around | space-evenly */

  /* Cross axis alignment */
  align-items: stretch;          /* stretch | flex-start | flex-end | center | baseline */

  /* Multi-line cross axis alignment (only when flex-wrap: wrap) */
  align-content: normal;         /* normal | flex-start | flex-end | center | space-between | space-around | space-evenly | stretch */

  /* Gap between items */
  gap: 16px;             /* gap: row-gap col-gap */
  row-gap: 16px;
  column-gap: 24px;
}

फ्लेक्स आइटम गुण

.item {
  /* flex-grow: how much to grow (0 = don't grow) */
  flex-grow: 1;          /* 0 = don't grow, 1 = grow proportionally */

  /* flex-shrink: how much to shrink (1 = shrink proportionally) */
  flex-shrink: 0;        /* 0 = don't shrink */

  /* flex-basis: initial size before growing/shrinking */
  flex-basis: 200px;     /* auto | 0 | 200px | 25% */

  /* Shorthand: grow shrink basis */
  flex: 1 1 auto;        /* flex: 1 (common) | flex: 0 0 200px | flex: auto */

  /* Self alignment (overrides align-items for this item) */
  align-self: center;    /* auto | stretch | flex-start | flex-end | center | baseline */

  /* Order: visual order (default: 0) */
  order: -1;             /* appears before order:0 items */
}

सामान्य फ्लेक्सबॉक्स पैटर्न

उत्तम केन्द्रीकरण

/* Center anything horizontally and vertically */
.center-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

/* Or use margin: auto on the child (works when parent is flex) */
.centered-item {
  margin: auto;
}

नेविगेशन पट्टी

<nav class="navbar">
  <a href="/" class="logo">TechPulse</a>
  <ul class="nav-links">
    <li><a href="/blog">Blog</a></li>
    <li><a href="/about">About</a></li>
  </ul>
  <a href="/contact" class="cta">Get Started</a>
</nav>

.navbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 64px;
}

.logo { font-weight: bold; }

.nav-links {
  display: flex;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;              /* push CTA to right */
  justify-content: center;
}

.cta { margin-left: auto; }  /* or use flex: 1 on nav-links

समान ऊंचाई के साथ कार्ड लेआउट

.card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.card {
  display: flex;
  flex-direction: column;
  flex: 1 1 300px;     /* grow, shrink, min-basis 300px */
  max-width: 400px;
  background: white;
  border-radius: 12px;
  padding: 24px;
}

.card-content {
  flex: 1;             /* grows to fill space, pushes button to bottom */
}

.card-button {
  margin-top: 16px;    /* always at bottom regardless of content height */
}

चिपचिपा पाद

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;             /* grows to fill remaining space, pushing footer down */
}

footer {
  /* Always at bottom */
}

होली ग्रेल लेआउट

.layout {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.layout-header,
.layout-footer { flex: none; }

.layout-body {
  display: flex;
  flex: 1;
}

.layout-sidebar { width: 250px; flex: none; }
.layout-main    { flex: 1; }        /* fills remaining space */
.layout-aside   { width: 200px; flex: none; }

फ्लेक्स-रैप के साथ रिस्पॉन्सिव लेआउट

/* Items stack vertically on mobile, go horizontal on desktop */
.responsive-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.responsive-item {
  flex: 1 1 250px;     /* min-width 250px, grows to fill */
}

/* Force break: half-width items */
.half-width {
  flex: 1 1 calc(50% - 16px);
  max-width: calc(50% - 16px);
}

/* Full-width override */
.full-width {
  flex-basis: 100%;
}

फ्लेक्सबॉक्स बनाम ग्रिड: प्रत्येक का उपयोग कब करें

परिदृश्य फ्लेक्सबॉक्स का प्रयोग करें ग्रिड का प्रयोग करें
नेविगेशन पट्टी
कार्ड सूची एक पंक्ति में
जटिल 2डी लेआउट
किसी तत्व को केन्द्रित करें
फॉर्म लेआउट ✅ (सरल) ✅ (जटिल)
पृष्ठ लेआउट (शीर्षलेख/मुख्य/पाद लेख)
आइटम ऑटो-प्लेसमेंट

फ्लेक्सबॉक्स महारत किसी भी वेब डेवलपर के लिए आवश्यक है। The combination offlex: 1बढ़ती वस्तुओं के लिए,gapरिक्ति के लिए,align-itemsक्रॉस-अक्ष संरेखण के लिए, औरflex-wrap: wrapरिस्पॉन्सिव लेआउट के लिए वास्तविक दुनिया के 90% उपयोग के मामले शामिल हैं।

✍️ Leave a Comment

Your email address will not be published. Required fields are marked *

🌐 Read in:🇬🇧 English🇩🇪 Deutsch🇧🇷 Português🇸🇦 العربية🇮🇳 हिन्दी🇧🇩 বাংলা