Web development · Lesson 03
Make a layout that adapts
Build a simple layout that remains readable on small and large screens.
- Describe the difference between flex and grid
- Use a responsive rule to adjust a layout
Helpful background: Basic HTML elements and CSS selectors.
Start with the content
A good layout gives content room to breathe and keeps the reading order clear. Decide what should sit beside what, then choose a layout tool that fits.
Flexbox for a row or column
Flexbox is useful when items need to line up in one direction. It can distribute space and wrap items as the available width changes.
Grid for two dimensions
CSS Grid is useful when you want to define rows and columns together. A small media query can switch a two-column layout into a single column on narrow screens.
.cards {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 1rem;
}
@media (max-width: 42rem) {
.cards { grid-template-columns: 1fr; }
}Which CSS tool is designed to manage rows and columns together?
Your turn
Plan a card section with two columns on a wide screen and one column on a phone. Which rule changes the layout?
Use grid-template-columns: repeat(2, 1fr) by default, then set grid-template-columns: 1fr inside a max-width media query.
BUILT TOGETHER
Help make this explanation better.
Have a clearer explanation, a useful example, or a correction? Share it with the community.
Be the first to add your name when you improve this lesson.
How to get credited