← Pages with Bootstrap

Pages with Bootstrap: recap

For after the lessons: one card per lesson, to check what you remember. Answer each question in your head or on paper first, then check it. Nothing here is marked.

Ready-made parts

1. Style by class names

Try firstWhy does class="btn btn-primary" make a blue button when you wrote no CSS?

Check your answer

The linked stylesheet, bootstrap.min.css, has rules for btn and btn-primary; the class names switch them on.

  1. Link Bootstrap's stylesheet with one line at the top of the page.
  2. Its rules apply at once, to the whole page.
  3. Add its class names to style a tag: btn for the button shape, btn-primary for the colour.
  4. No CSS of your own: you look the class names up.
The page this code makes
What this code makes
Link Bootstrap, then style by adding its class names · Sound on for the voiceover
Open the lesson →

2. Navbar, cards and a grid

Try firstWhat goes inside a row, and what goes inside a col?

Check your answer

Cols go inside a row and share its width; the content, such as a card, goes inside a col.

  1. A row is a line of columns.
  2. Put a col inside it, and a card inside the col: one col takes the whole row.
  3. Add a second col: the two share the row equally.
  4. No Flexbox rules of your own: Bootstrap's row and col do the layout.
The page this code makes
What this code makes
A row holds cols; each col shares the width; a card goes inside a col · Sound on for the voiceover
Open the lesson →

3. Make Bootstrap yours

Try firstYour rule .card { border-color: teal; } does nothing. What is the first thing to check?

Check your answer

Whether the style block comes after the Bootstrap link; when two rules match equally, the later one wins.

  1. A Bootstrap card has Bootstrap's grey border.
  2. Your style block comes after the link.
  3. Your rule for the same class sets a teal border: both rules match, and the later one, yours, wins.
  4. Bootstrap gives the shapes and the grid; your rules give the look.
The page this code makes
What this code makes
Your own rules go after the Bootstrap link, so they win · Sound on for the voiceover
Open the lesson →