Flexbox: Reordering Content
Master Flexbox order property for responsive layouts
Key Learning Objectives
Order Property Mastery
Learn how to manipulate flex item order using positive and negative values. Understand how order values interact with default positioning.
Mobile-First Strategy
Implement mobile-first development principles where HTML order reflects logical mobile layout, then adjust for desktop.
Responsive Reordering
Apply different item orders across screen sizes using media queries for optimal user experience.
Exercise Setup Process
File Preparation
Close existing files and navigate to Desktop > Class Files > yourname-Flexbox Grid Class > Flexbox Reorder Content folder
Open Project Files
Open index.html from the Flexbox Reorder Content folder in your code editor
Preview and Test
Open index.html in browser and resize window to observe different layouts at various screen sizes
Analyze Current Order
Note how navbar and footer items display differently in mobile vs desktop views
The order property only works on flex items. Elements must be direct children of a flex container to be reorderable.
Order Value Effects
| Feature | Negative Values | Positive Values |
|---|---|---|
| Default Comparison | Less than 0 (moves earlier) | Greater than 0 (moves later) |
| Example: order: -1 | Moves to beginning | Not applicable |
| Example: order: 1 | Not applicable | Moves to end |
| Default Value | All flex items start at 0 | All flex items start at 0 |
Strategic Order Assignment
Set Base Order
Assign all navbar list items order: 5 to create numbered space for specific positioning
Position Logo First
Set navbar logo to order: 1 to ensure it appears at the beginning
Order Navigation Items
Assign order: 2 to Excursions and order: 3 to Sign Up for desired sequence
Leave Remaining Default
About and Contact keep order: 5, appearing after specifically ordered items
Use higher default numbers (like 5) for groups of items to leave room for inserting specific items at lower numbers (1, 2, 3) in desired positions.
Final Layout Result
Logo
First position with order: 1
Excursions
Second position with order: 2
Sign Up
Third position with order: 3
About & Contact
Final positions with order: 5
Key Takeaways
