Full-Stack course / Tools and the web
Clinic hours at different widths
How to fetch and submit this exercise
Once: install the tool and connect your account.
curl -fsSL https://gonomicon.com/install.sh | sh
gonomicon loginEach exercise: download it, edit the file named in the instructions, then submit.
gonomicon fetch fs-week-1/06-03-clinic-hours-responsive
cd 06-03-clinic-hours-responsive
gonomicon submitGoal
Style the clinic-hours entries so they stack in one column on narrow screens and form a two-column grid on wide screens.
Example
A one-column grid keeps each entry on its own row:
.schedule {
display: grid;
grid-template-columns: 1fr;
}
On a wider screen, a media query can change the number of columns. For example, a layout could switch at 52rem and use two equal columns once the viewport is wide enough.
Rules
- Edit only
styles.css. The providedindex.htmlalready links to it and contains four.clinic-hours__entryelements inside.clinic-hours. - Outside media queries,
.clinic-hoursmust use CSS Grid with exactly one column. - Add a
min-width: 52remmedia query that changes.clinic-hoursto two equal columns. - At a viewport width of 360px, the entries must remain in one column and the page must not have horizontal overflow. At 900px, the entries must use two columns.
- Keep all four entries visible and in the existing HTML order. Do not hide entries or change the HTML.
- Do not use JavaScript to change the layout.
What you'll practice
Building a mobile-first grid, then using a min-width media query to make use of extra space on a wide screen.
Run it
gonomicon fetch fs-week-1/06-03-clinic-hours-responsive
cd 06-03-clinic-hours-responsive
gonomicon test
gonomicon submit
Hints
- Start with
.clinic-hoursoutside any media query. Its default grid should have one column, so the narrow layout works before the wide-screen rule applies. - Use a
min-widthmedia query with the exact52rembreakpoint; inside it, change the grid to two columns. - Long labels should be allowed to shrink inside their grid cells. Check the page at 360px and make sure it does not create horizontal overflow.