Introduction to Flexbox - Guided Notes

CSCI 3403 - Web Programming | Day 13

Name: _________________________________ Date: _____________

🎯 Today's Goal: Master the fundamentals of Flexbox positioning - the modern way to layout web pages!

📦 What is Flexbox?

Flexbox stands for _________________ Box Layout

Why Flexbox was Revolutionary:

Before Flexbox, developers used:

What Flexbox Provides:

  1. _________________________________________
  2. _________________________________________
  3. _________________________________________
  4. _________________________________________

🎨 Core Concepts

The Two Key Players:

Component CSS Property What It Does
Flex Container (Parent) _________________ _________________________________________
Flex Items (Children) Automatic _________________________________________
💡 Remember: Only _________________ children become flex items!

Basic Flexbox Code:

.container { _________: flex; } /* Children automatically become flex items! */

🛠️ Flexbox Properties

Container Properties (Applied to Parent):

Property Common Values What It Controls
flex-direction _________________ Main axis direction
justify-content _________________ Alignment on main axis
align-items _________________ Alignment on cross axis
flex-wrap _________________ Allow items to wrap
gap _________________ Space between items

Item Properties (Applied to Children):

Property Default Value What It Controls
flex-grow _____ _________________________________________
flex-shrink _____ _________________________________________
flex-basis _____ _________________________________________
align-self auto _________________________________________

📐 Understanding Axes

Main Axis vs Cross Axis

When flex-direction is row (default):

When flex-direction is column:

🎯 Key Rule: justify-content works on the _________________ axis, align-items works on the _________________ axis

🎨 Common Flexbox Patterns

1. Perfect Centering

.center-everything { display: _________; justify-content: _________; align-items: _________; }

2. Navigation Bar (Logo - Nav - Button)

.navbar { display: _________; justify-content: _________; align-items: _________; }

3. Card Layout with Wrapping

.card-container { display: _________; flex-wrap: _________; gap: _________; }

💻 Practice Exercise: Build a Header

Challenge Requirements:

Your Solution:

.header { display: _________; justify-content: _________; align-items: _________; padding: _________; } .nav { display: _________; gap: _________; }

Sketch Your Layout:

Draw your header layout here






⚠️ Common Flexbox Gotchas

  1. Margin Collapse:
  2. Properties that don't work on flex items: _________, _________, _________
  3. Default flex-shrink value: _____ (What does this mean? _________________________________________)
  4. Only direct children:

🛠️ DevTools Tips for Flexbox

Essential DevTools features for debugging Flexbox:

  1. Look for the _________________ badge in Elements panel
  2. Use the _________________ tab to see flex properties
  3. Check _________________ styles to see actual values
  4. Use _________________ editing to test changes
Pro Tip: If something isn't working, _________________ it first!

🌍 Real-World Applications

Where You'll Use Flexbox:

UI Components Responsive Design
_________________ _________________
_________________ _________________
_________________ _________________
_________________ _________________

🎯 Key Takeaways

Complete these statements:

  1. To create a flex container, I use:
  2. Direct children automatically become:
  3. For horizontal alignment on the main axis, I use:
  4. For vertical alignment on the cross axis, I use:
  5. Elements can be both a flex container AND:

📚 HOMEWORK REMINDER

Complete The Odin Project section:

"Flexbox - Growing and Shrinking"

Due before next class!

📚 Resources

Interactive Learning:

Documentation:

📝 Additional Notes

Use this space for any additional notes during the lecture: