MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Flexbox Architecture: Justify, Align, Direction, Wrap & Gap0%
Study Materials
Tailwind CSSProgress 0%
1.1Why Tailwind CSS? Utility-First vs Traditional Semantic CSS1.2Installation via PostCSS, Vite & Next.js Framework Integration1.3Tailwind Core Spacing, Sizing, Padding & Margin Scales1.4Typography: Font Families, Sizes, Weights, Leading & Tracking
2.1Flexbox Architecture: Justify, Align, Direction, Wrap & Gap2.2CSS Grid System: Template Columns, Rows, Col-Span & Gap2.3Mobile-First Responsive Design with Breakpoint Prefixes (sm, md, lg, xl)2.4Positioning, Z-Index, Floats, Overflows & Aspect Ratio Utilities
HomeTutorialsTailwind CSSFlexbox Architecture: Justify, Align, Direction, Wrap & Gap
CSS Grid System: Template Columns, Rows, Col-Span & Gap

Flexbox Architecture: Justify, Align, Direction, Wrap & Gap

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

Modern web navigation bars, card lists, button groups, and modal layouts rely heavily on CSS Flexbox. Tailwind CSS transforms Flexbox into a concise, declarative toolkit that eliminates cumbersome flex container boilerplate.


1. Initializing a Flex Container

To activate flex layout, apply the flex utility to a container:

1<div class="flex items-center justify-between p-4 bg-white shadow-sm">
2 <div class="font-bold text-lg text-primary">MSK Institute</div>
3 <nav class="flex items-center gap-6">
4 <a href="/courses" class="text-slate-600 hover:text-primary">Courses</a>
5 <a href="/tutorials" class="text-slate-600 hover:text-primary">Tutorials</a>
6 <button class="px-4 py-2 bg-secondary text-white rounded-lg">Enroll</button>
7 </nav>
8</div>

2. Direction & Wrapping

ClassCSS EquivalentDescription
flex-rowflex-direction: row;Default horizontal layout (left to right)
flex-colflex-direction: column;Vertical layout (top to bottom)
flex-row-reverseflex-direction: row-reverse;Reverse horizontal order
flex-wrapflex-wrap: wrap;Allows items to wrap onto next line when full
flex-nowrapflex-wrap: nowrap;Forces all items onto a single overflowing row

3. Main-Axis (justify) vs Cross-Axis (items) Alignment

1<!-- Justify content along main axis -->
2<div class="flex justify-start">Align Left</div>
3<div class="flex justify-center">Center along main axis</div>
4<div class="flex justify-between">Space evenly with first/last at edges</div>
5<div class="flex justify-evenly">Equal spacing around all items</div>
6 
7<!-- Align items along cross axis -->
8<div class="flex items-center">Center items vertically in row</div>
9<div class="flex items-start">Align to top edge</div>
10<div class="flex items-end">Align to bottom edge</div>
11<div class="flex items-baseline">Align by text baseline</div>

4. Spacing Items with gap

Never use manual mr-4 on flex children; use the container gap utility:

1<div class="flex gap-4">
2 <!-- Equal 16px space between items, zero space on outer edges! -->
3 <div class="p-4 bg-slate-100 rounded">Item 1</div>
4 <div class="p-4 bg-slate-100 rounded">Item 2</div>
5 <div class="p-4 bg-slate-100 rounded">Item 3</div>
6</div>

5. Flex Child Sizing: flex-1, grow, and shrink-0

1<div class="flex items-center gap-3">
2 <!-- Avatar never shrinks even if screen shrinks -->
3 <img src="/avatar.jpg" class="w-12 h-12 rounded-full shrink-0" alt="User">
4
5 <!-- Content expands to fill all remaining horizontal width -->
6 <div class="flex-1 min-w-0">
7 <h5 class="font-bold truncate">Er. Sumit Kumar</h5>
8 <p class="text-xs text-slate-500 truncate">Lead Instructor at MSK</p>
9 </div>
10
11 <!-- Action button remains at native width -->
12 <button class="shrink-0 px-3 py-1 bg-blue-500 text-white rounded">Follow</button>
13</div>

Interactive Quiz• Knowledge Check

Multiple Choice Questions

Question 1
Which Tailwind class combination horizontally and vertically centers a single child element inside a flex container?
Question 2
Why is using gap-4 on a parent flex container preferred over applying mr-4 to each flex child?
Question 3
What does the shrink-0 utility class do when applied to a flex child?
Question 4
Which class switches a horizontal flex layout into a vertical stack?
Question 5
What is the effect of flex-1 on a child element?

Next Lesson

CSS Grid System: Template Columns, Rows, Col-Span & Gap

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Typography: Font Families, Sizes, Weights, Leading & TrackingCSS Grid System: Template Columns, Rows, Col-Span & Gap

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master Tailwind CSS with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext