Codeloft
0 0 XP

Responsive design

8 min 20 XP + 10 for no hints

People open pages on phones, tablets and laptops. A responsive page changes its layout to fit each one.

A media query applies CSS only when a condition is true. @media (max-width: 600px) { … } means "only on screens 600 pixels wide or narrower".

A common pattern: cards sit side by side on wide screens, then stack in one column on phones with flex-direction: column. The checks open your page at phone width and at laptop width to test both.

Example
<style>
  .row { display: flex; gap: 8px; }
  .row div { flex: 1; background: #bbf7d0; padding: 12px; }
  @media (max-width: 600px) {
    .row { flex-direction: column; }
  }
</style>
<div class="row"><div>A</div><div>B</div><div>C</div></div>
Rules inside a media query sit inside its own braces, so you'll see two closing braces at the end.

Your tasks

1 of 3 done
  1. Add a media query for screens up to 600px wide
  2. On a phone (360px wide), stack the cards in a column
  3. On a laptop, keep the cards side by side

Quick check

When does @media (max-width: 600px) apply its CSS?

cards.htmlUpdates as you type