topskill.dev
CoursesTracks
0
All courses/CSSResponsive Grid
Grid
7 / 9
← CSS
○CSS Rule Style an Exhibit Card○Write Your First CSS Rule○CSS Selectors Target Exhibit Details○Target Exhibit Details○Apply CSS Three Sources○Apply CSS Three Ways○Specificity Resolve a Style Conflict○Resolve Specificity○Inheritance and the cascade✦Module Quiz
○Color Palette○Color Palette○Background Layer○Background Layer○Type Rhythm○Type Rhythm○Borders and Shadows○Borders and Shadows✦Module Quiz
○Box Model Seed Packet Card○Space a Seed Packet○Display Swap Table Labels○Arrange Swap Table Labels○Positioning Pickup Pin○Pin the Pickup Location○Sizing and Overflow○Size a Seed-Swap Notice○Sticky scroll headings✦Module Quiz
○Advanced Selectors Book Cart Sign○Target a Book Cart Sign○Pseudo-Classes Night Cart States○Style Night Cart States○Pseudo-Elements○Add a Book-Quote Mark✦Module Quiz
○Lantern Market navigation○Lantern Market navigation✦Module Quiz
○Community garden request card○Community garden request card✦Module Quiz
○Flex Direction○Flex Direction○Main-Axis Spacing○Main-Axis Spacing○Cross-Axis Alignment○Cross-Axis Alignment○Wrapping and Flex Items○Wrapping and Flex Items○Flexbox Navigation○Flexbox Navigation✦Module Quiz
○Grid Tracks○Grid Tracks○Grid Gaps○Grid Gaps○Grid Placement○Grid Placement●Responsive Grid○Responsive Grid✦Module Quiz
○River radio schedule○Harbor radio schedule✦Module Quiz
○Field note color system○Field note color system○Transforms○Rotate a Field Note○Resilient styles✦Module Quiz
○Kite festival signal○Garden festival signal✦Module Quiz
○Garden forecast○Harbor forecast○Fluid sizing○Fluid weather bulletin○Images that fit✦Module Quiz
○Seed inventory table○Tool checkout table✦Module Quiz
○Community maker profile○Maker profile sheet✦Module Quiz

Responsive Grid

Switch the workshop board to one column

Three columns fit a wide board, but each card gets cramped in a narrow preview. A media query applies a set of CSS rules only when a condition is true. This example checks the viewport, the area where the page is displayed. In this course, that is the preview frame's width, not necessarily the whole browser window.

The ordinary .responsive-grid rule defines three columns. Later in style.css, this rule replaces that column definition when the viewport is at most 36rem wide:

css
@media (max-width: 36rem) {
  .responsive-grid {
    grid-template-columns: 1fr;
  }
}

The outer braces enclose the conditional rules; the inner braces enclose the declarations for .responsive-grid. max-width includes the boundary itself. In a media query, rem uses the browser's initial font size, usually 16px, so 36rem is normally 576px. Changing the page's root font size does not change this query's threshold.

Both rules target the same class. On a narrow viewport both apply, and the later column declaration wins. Above the threshold, the media query no longer applies, leaving three columns. The display and gap declarations keep working at both sizes.

Run Preview, then resize the preview across the threshold in both directions. Watch for one column on the narrow side and three on the wide side. If your preview cannot resize, temporarily use 100rem to inspect the narrow-layout rule, then restore 36rem; that experiment does not replace checking the actual breakpoint. The Responsive Design module will build on this first media query.

Hint 1
1 / 2
HINT 1

Open style.css and change one declaration at a time.

HINT 2

Run Preview after each change; restore the value before the exercise.

Files
  • ⋄index.html
  • ⋄style.css
Loading editor…