Skip to content
engineering workbench.by StudyPort Academy
Learning path
Advanced24 minLESSON 16 / 16

Build a responsive layout

This is the page those lessons were heading toward. The HTML names the regions. The CSS gives them a box model, a narrow arrangement, and a wider one. Nothing here is a new kind of CSS.

Opening editor…
LIVE PREVIEW
Console 0

Your console output appears here.

Saved on this deviceJavaScript · ES2022

The console read the main landmark, two notes, the notes link, and the main id. The layout lives in the CSS tab. The project catalog is the same page with room to change it.

+Go deeper

One document

The header, the nav, and the main are the elements from the HTML lessons. does not add a second file for phones. The same articles are on the page at every width.

The box model on the page

border-box on the page means a note with padding keeps the width you declared. That is the doing the job you already practiced. A content-box note with width 100 percent and padding would spill out of the column.

Flex and grid together

The header is : the title and the link sit on one row with space between them. The notes are with one column in the base CSS. Flex was the right tool for a single row. Grid was the right tool once the notes needed columns.

Which tool does which job on this page
PieceToolWhy
Page padding and note paddingborder-boxThe declared width includes the padding
Header title and linkflexboxOne row, space between the two ends
NotesgridOne column, then two when there is room
The wide arrangementmin-width queryThe narrow CSS stays complete

The query adds the wide layout

The at 40rem sets the page to a row so the nav can sit beside main, and it sets two grid columns. Under that width the base column remains. The meta element from the first lesson is what makes a phone measure 40rem against its own width.

Change it in the catalog

The project uses this page as the starting file. Change the sidebar width, let one note span both columns, or move the query. The HTML stays one document. The script in the sandbox only checks that the landmarks are still there.

04

Guided challenge

Build a responsive layout

The notes link is inside the header with class bar. The script looks for a menu that is not in the HTML. Read the link in the bar.

Opening editor…
LIVE PREVIEW
Console 0

Your console output appears here.

Saved on this deviceJavaScript · ES2022

EXPECTED CONSOLE OUTPUT

main
2
#notes
notes

Hints 0/2

    Use all hints or make 3 failed runs (0/3).

    05

    Free sandbox

    Edit the HTML and CSS. The JavaScript tab can read the result. This draft is saved separately.

    Opening editor…
    LIVE PREVIEW
    Console 0

    Your console output appears here.

    Saved on this deviceJavaScript · ES2022
    06

    Quiz

    A quick check for understanding. Retry as often as you like; your learning path stays open.

    01What changes between the narrow and wide arrangements?
    02Why is the header flex and the notes grid?

    Ready to call this one understood?

    Mark this lesson complete to earn 200 XP. You can always revisit it.

    Sign in to save progress