Practice and reinforce the concepts from Lesson 7
In these activities, you will:
block
, inline
, inline-block
, flex
)Welcome to the CSS Display Activities! This comprehensive set of activities will help you master CSS display properties and reinforce fundamental web design concepts. You'll work through 5 hands-on activities that build upon each other, covering everything from basic display properties to advanced Flexbox layouts.
Total estimated time: 2.5-3 hours
💻 Hands-on Coding Activity | Time: 30-35 minutes
Focus: Basic CSS Display Properties
Learning Objectives:
block
, inline
, and inline-block
Platform: CodePen or StackBlitz
Instructions:
Starter Code:
<div class="container">
<div class="box block">Block Element</div>
<div class="box inline">Inline Element</div>
<div class="box inline-block">Inline-Block Element</div>
<span class="box inline">Inline Span</span>
<span class="box block">Block Span</span>
</div>
.container {
border: 2px solid #333;
padding: 20px;
margin: 20px;
}
.box {
background-color: #e74c3c;
color: white;
padding: 10px;
margin: 5px;
border: 2px solid #c0392b;
}
/* Experiment with these display values */
.block {
display: block;
}
.inline {
display: inline;
}
.inline-block {
display: inline-block;
}
Tasks:
display: none
and see what happensdisplay: flex
on the container💡 Tip Use browser DevTools to inspect elements and see their computed display values. Right-click any element and select "Inspect"!
🎨 Design & Coding Activity | Time: 35-40 minutes
Focus: Practical Application of Display Properties
Learning Objectives:
inline-block
works for horizontal layoutsPlatform: CodePen or StackBlitz
Instructions:
Challenge Code:
<nav class="navbar">
<div class="nav-brand">My Website</div>
<ul class="nav-menu">
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
Your Tasks:
display: inline-block
Bonus Challenge:
💡 Tip Use
display: none
to hide elements anddisplay: block
to show them in responsive designs!
💻 Advanced Coding Activity | Time: 40-45 minutes
Focus: CSS Flexbox Layout System
Learning Objectives:
Platform: CodePen or StackBlitz
Instructions:
Starter Code:
<div class="card-container">
<div class="card">
<h3>Card 1</h3>
<p>This is the first card with some content.</p>
<button>Learn More</button>
</div>
<div class="card">
<h3>Card 2</h3>
<p>This is the second card with different content.</p>
<button>Learn More</button>
</div>
<div class="card">
<h3>Card 3</h3>
<p>This is the third card with more content.</p>
<button>Learn More</button>
</div>
</div>
Your Tasks:
display: flex
justify-content
to center the cards horizontallyalign-items
to align cards verticallyflex-wrap
to make cards wrap on smaller screensflex-direction
(row, column, row-reverse)Advanced Challenges:
💡 Tip Start with
display: flex
on the parent container. Then usejustify-content: center; align-items: center;
for perfect centering!
🎨 Creative Coding Activity | Time: 35-40 minutes
Focus: Advanced Flexbox and Responsive Design
Learning Objectives:
Platform: CodePen or StackBlitz
Instructions:
Challenge: Build an image gallery that:
Sample Structure:
<div class="gallery">
<div class="gallery-item">
<img src="https://picsum.photos/300/200?random=1" alt="Gallery Image 1">
</div>
<div class="gallery-item">
<img src="https://picsum.photos/300/200?random=2" alt="Gallery Image 2">
</div>
<!-- Add more gallery items -->
</div>
Your Tasks:
display: flex
and flex-wrap
flex-basis
to control item widths💡 Tip Use
flex: 1
for equal-width items, orflex-basis: 25%
for specific widths!
🏗️ Project Activity | Time: 45-50 minutes
Focus: Real-world Application of CSS Display Properties
Learning Objectives:
Platform: CodePen, StackBlitz, or your preferred code editor
Instructions:
Website Requirements:
Sample Structure:
<header class="header">
<nav class="nav">
<div class="logo">Your Brand</div>
<ul class="nav-menu">
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<main class="main-content">
<article class="content">
<h1>Welcome to Our Website</h1>
<p>This is the main content area...</p>
</article>
<aside class="sidebar">
<h3>Related Links</h3>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
</ul>
</aside>
</main>
<footer class="footer">
<p>© 2024 Your Website. All rights reserved.</p>
</footer>
Your Tasks:
display: flex
for the main layout structureBonus Features:
💡 Tip Use CSS Grid for the main layout and Flexbox for component layouts. This gives you the best of both worlds!
Follow these steps to complete the activities successfully:
⚠️ Important Complete all activities before submitting your project. Each activity builds essential skills needed for the final submission.
ℹ️ Ready to submit? When you have completed all CSS Display activities, submit your work using the form below:
Submit Your CSS Display Project
Make sure your submission includes:
- Screenshots or links to all 5 activities
- A brief explanation of what you learned
- Any challenges you encountered and how you solved them
- Your final website layout from Activity 5
display: flex
on the parent containerflex: 1
for equal distribution of spaceRemember: These activities are designed to reinforce your understanding of CSS display properties and modern web design. Take your time to understand each concept thoroughly before moving forward. Practice makes perfect!
Next Steps: After completing these activities, you'll be ready to tackle more advanced CSS concepts like CSS Grid, animations, and advanced responsive design techniques.