Lesson 3.7: Flexbox – One-Dimensional Layouts
Flexbox (Flexible Box Layout) is a modern CSS layout system designed to arrange elements in one dimension—either row (horizontal) or column (vertical). It makes it much easier to design responsive and dynamic layouts compared to traditional CSS methods like floats or tables.
🔹 Key Concepts of Flexbox
-
Flex Container – The parent element that holds flex items.
-
Flex Items – The child elements inside the flex container.
They automatically adjust size and position according to container rules.
🔹 Flexbox Properties for Container
-
flex-direction – Defines the direction of items.
-
justify-content – Aligns items horizontally.
-
align-items – Aligns items vertically.
-
flex-wrap – Controls wrapping of items.
🔹 Flexbox Properties for Items
-
flex-grow – Defines how much an item can grow.
-
flex-shrink – Defines how items shrink if space is small.
-
flex-basis – Defines initial size of an item before growing/shrinking.
-
align-self – Overrides
align-itemsfor a single item.
🔹 Example
✅ Summary:
-
Flexbox = one-dimensional (row/column) layouts.
-
justify-content→ horizontal alignment. -
align-items→ vertical alignment. -
flex-grow,flex-shrink,flex-basis→ control item sizes.
