90-minute class plan
- 0–10 min — Opening and visual warm-up: Introduce the learning goals, review the previous class, and discuss a relevant website example.
- 10–25 min — Mini-lesson: Explain the key concepts and show examples. Keep the presentation focused on what students will apply.
- 25–45 min — Instructor demonstration: Walk through the interactive CodePen or a live example. Pause for predictions and questions.
- 45–70 min — Guided and independent practice: Students complete the lesson exercise, first following a short demonstration and then making their own decisions.
- 70–83 min — Apply and critique: Students connect the skill to their website project, compare results with a partner, and make one improvement.
- 83–90 min — Share-out and exit ticket: Review key takeaways and ask students to identify one thing they learned and one next step.
Course: Introduction to Web Design
Week: 7
Learning objectives
By the end of this lesson, you should be able to:
- Distinguish common uses of Flexbox and CSS Grid.
- Control columns, gaps, and item spans in a grid.
- Explain how a layout should adapt to different viewport sizes.
Key concepts
Flexbox is useful for arranging items along one primary axis, such as navigation links or a group of buttons. CSS Grid is designed for layouts that need coordinated rows and columns.
Responsive design means a layout adapts to its available space. This may involve changing column counts, adjusting spacing, resizing typography, or changing navigation. A responsive layout should preserve the content’s purpose and usability—not merely shrink a desktop design.
Choose the layout pattern based on content, hierarchy, and the behavior people need.
Interactive demonstration
Demo file: 06-css-grid-playground.html
Experiment with the CSS Grid Playground and Flexbox Playground. Change columns, gaps, item spans, direction, alignment, and wrapping. Resize your browser to test the layout.
See the Pen 06-css-grid-playground by Nicholas D’Angelo (@ndangelo) on CodePen.
Build a responsive card grid with at least six items. At wide widths, use multiple columns; at narrow widths, make content easy to read without horizontal scrolling. Use Flexbox for one component and Grid for another.
Connection to your website project
Apply responsive layout principles to the midterm site and test it at mobile and desktop widths.
Sublime Text coding lab
Complete this coding task in Sublime Text, save the files using the names below, and open the HTML page in a browser to test it.
Today’s coding focus
Flexbox, CSS Grid, responsive breakpoints, and mobile-first testing
Project files and folder structure
Create week-07/index.html and week-07/css/styles.css.
Syntax to practice
display: flex, gap, justify-content, align-items, display: grid, grid-template-columns, minmax(), and @media queries.
Build it
Build at least three cards using Grid or Flexbox. Add a breakpoint that changes the layout from multiple columns to one column. Test at approximately 375px, 768px, and 1280px.
Code along: Build a three-card grid and stack it on narrow screens.
Open in Sublime Text: week-07/css/styles.css
Type the example below, save the file, and read the comments and selectors carefully. Use this as a starting point, then modify it for your own project.
.card-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 20px;
}
.card { padding: 24px; background: white; border: 1px solid #cbd5e1; }
@media (max-width: 600px) {
.card-grid { grid-template-columns: 1fr; }
}
Complete HTML and CSS example
These are matching files. Create the folders shown below, save each code sample using the exact filename, and keep the stylesheet link consistent with your folder structure.
HTML file: week-07/index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Responsive Card Layout</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<main class="card-grid">
<article class="card"><h2>Design</h2><p>Explore visual ideas and layouts.</p></article>
<article class="card"><h2>Develop</h2><p>Build pages with HTML and CSS.</p></article>
<article class="card"><h2>Test</h2><p>Check designs on different screens.</p></article>
</main>
</body>
</html>
CSS file: week-07/css/styles.css
body { margin: 0; padding: 24px; font-family: Arial, sans-serif; background: #f1f5f9; color: #172033; }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.card { padding: 24px; background: white; border: 1px solid #cbd5e1; border-radius: 8px; }
@media (max-width: 600px) {
.card-grid { grid-template-columns: 1fr; }
}
@media (min-width: 601px) and (max-width: 900px) {
.card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
Important: The HTML links to css/styles.css. Keep that path correct relative to the HTML file.
Modify it
Change to two columns, then change the breakpoint from 600px to 800px. Test at 375px, 768px, and 1280px.
Save and test
- Save the file in the exact folder shown above.
- Open the HTML file in a browser, or refresh it after saving if it is already open.
- Check that linked CSS, images, and navigation work. If something fails, inspect filenames, capitalization, nesting, and relative paths.
Assignment and required deliverables
Submit every item below. Use the specified filenames and folder structure. A screenshot does not replace a required source file.
Required files
week-07/index.htmlandweek-07/css/styles.css— responsive page with at least three cards and a media query.week-07/responsive-tests.pdfor.png— screenshots at approximately 375px, 768px, and 1280px.week-07/README.txt— layout technique, breakpoint, and one issue corrected.
Submission checklist
- Three cards; no horizontal overflow at three widths; Flexbox or Grid and at least one media query.
- Keep all HTML, CSS, image, text, and PDF files inside the named weekly or project folder.
- Open the HTML file in a browser before submitting and confirm linked CSS and images load.
Before you leave (3-minute exit check)
Write down one thing you changed, one thing you learned from the result, and one question you still have.
References
These references support the key concepts and practices covered in this lesson. They are provided for verification and further study.
- Mozilla Contributors. (n.d.). *Flexbox*. MDN Web Docs. https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/CSS_layout/Flexbox
- Mozilla Contributors. (n.d.). *CSS grid layout*. MDN Web Docs. https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/CSS_layout/Grids
- Mozilla Contributors. (n.d.). *Responsive web design*. MDN Web Docs. https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/CSS_layout/Responsive_Design