topskill.dev
CoursesTracks
0
All courses/CSSFluid sizing
Responsive Design
3 / 6
← 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

Fluid sizing

A breakpoint can flip a grid at a chosen width. This park forecast instead lets available space determine the layout between sizes.

In style.css, .page-shell uses width: min(90%, 46rem). min() chooses the smaller value, so the page takes 90% of its container until it reaches the 46rem cap.

.bulletin uses repeat(auto-fit, minmax(12rem, 1fr)) for its columns. A column needs at least 12rem. When two columns and their gap fit, the cards share a row instead of stacking.

The third decision belongs to .card: padding: clamp(.75rem, 2vw, 1.5rem) makes the inside spacing grow with the viewport, within limits. These rules control page width, column width, and padding separately. None needs a media query.

Read the units and limits

rem follows the root font size: with a 16px root, 12rem is 192px. A percentage width such as 90% follows the containing block. vw instead follows the preview viewport: 1vw is one hundredth of its width. Those are different reference sizes. max(1rem, 2vw) chooses the larger value, useful for enforcing a lower bound. calc(100% - 2rem) combines compatible lengths; keep spaces around + and -. For this example, min() already expresses the width cap without another calculation.

Read clamp(minimum, preferred, maximum) from left to right. Here padding follows 2vw only while that value sits between .75rem and 1.5rem; outside the range it stays at the nearest bound.

In repeat(auto-fit, minmax(12rem, 1fr)), auto-fit fits as many tracks as the container can hold and collapses unused ones. minmax() gives each track its lower and upper limits; 1fr shares the remaining space. If the container becomes narrower than even one 12rem track, that minimum can still cause overflow. Fluid sizing is not a promise that any content fits any width.

Try the demo

Resize the preview from narrow to wide and watch the cards move from a stack to a row. Change 12rem to 16rem briefly; the cards need more room before sharing a row. Restore the original value afterward.

Checkpoint: You can point to the width cap, the column minimum, and the padding bounds in the stylesheet. Next you will make similar choices for a different forecast.

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