P2.5: CSS Flexbox Layouts

Flexbox (Flexible Box Layout) is a 1D layout model that makes it incredibly easy to align elements, distribute space, and manage layouts.


1. Container & Child Mechanics

By applying display: flex; to a parent container, its children automatically become flexible elements:

  • justify-content: Aligns items along the main horizontal axis (e.g., center, space-between).
  • align-items: Aligns items along the cross vertical axis (e.g., center, stretch).
  • flex-direction: Dictates primary flow direction (row, column).

Common CSS Layout Engines Usage

Percentage of professional websites utilizing modern layout properties.

Rachel Andrew

Rachel AndrewView Profile 🔗

Real-World Developer Case Study
16 Years Exp
RoleCSS Working Group Invitee
Salary₹70 Lakhs/yr equivalent
CompanySmashing Magazine
Core Tech Stack
Flexbox specsCSS LayoutWeb Standards

Flexbox is perfect for rows, headers, sidebars, and component level alignments. It is best used for 1-dimensional layouts. Combine it with gap for clean item spacing!


🎓 Practice Assignment Tasks

  • Build a navigation bar with a logo on the left and links on the right using Flexbox.
  • Use `justify-content: space-between` and `align-items: center`.
Stuck? Hints available
/* Write your CSS styling rules here to complete the assignment */
🔒 Code requirements not met yet. Complete the tasks above.
🔒 Complete the Practice Assignment above to unlock completion.
Advertisement
NS
Ask Nextsem
AI Mode
NS
Home
Course
Playground