In the last video, you kept media queries for the layouts that change shape, such as the header’s row and the home page’s sidebar. Each one asks how wide the window is, which is the right question for a page. A card is different because it can sit in more than one place. Rosa wants Tomás’s volunteer card on the home page as well as on the volunteers page, two slots of very different widths.
In this lesson, you’ll make the volunteers’ cards stack on a phone, see why a media query can’t do that job once the same card sits in a sidebar, and replace it with a query that measures the card’s own slot. Start with the cards as they look on a phone today.
Stack the Cards on a Phone
The volunteers page still uses the media object from the layout course. Each .profile card is a flex row with a 160-pixel photo beside a .profile-text column. On a wide screen, that works well. On a phone, the photo keeps its 160 pixels and the text gets what’s left.
Open garden-practice/volunteers.html in device mode at 320 pixels and scroll to Rosa’s card. Her text is squeezed into a column about 88 pixels wide, a word or two per line:

You already know the mobile-first fix from the home page. Make the stacked layout the base, and then bring the row in with a query once there’s room. The card is a piece Rosa wants on more than one page, and its look already lives in the components layer, so its layout rules move there too.
In the layout layer of garden-practice/style.css, delete the three rules for .profile, .profile img, and .profile-text. Then, in the components layer, replace the .profile rule that sets margin-block with these three rules:
.profile {
display: flex;
flex-direction: column;
gap: var(--space-m);
margin-block: var(--space-l);
scroll-margin-top: 6rem;
}
.profile img {
width: 160px;
}
.profile-text {
min-width: 0;
overflow-wrap: anywhere;
}
The flex-direction: column line stacks the photo above the text, and the other lines come across from the old rules unchanged, apart from a smaller gap between the stacked photo and text. Right after them, still inside @layer components, add the query that turns the row back on:
@media (width >= 30rem) {
.profile {
flex-direction: row;
align-items: start;
gap: var(--space-l);
}
.profile-text {
flex: 1;
}
}