liveBook · Manning

Layout

As explained in Tiny CSS Projects

Layout is the spatial arrangement and positioning of content in a web page.

Layout is the spatial arrangement and positioning of content on a web page. A practical approach starts with narrow screens, then adds rules for wider screens so content uses available space without forcing small-screen overrides. section 8.0 section 5.2

Use layout techniques to solve common interface problems:

  • Arrange page regions, card containers, and card content across columns and rows with CSS Grid. section 5.2
  • Stack content on narrow screens, then expand it as the viewport grows with media queries. section 8.0 section 8.3
  • Constrain very wide pages with max-width and center them using automatic side margins. section 4.5.3
  • Build interactive card arrangements with Flexbox, positioning, backgrounds, and sizing. section 9.0

Centered responsive page

A newspaper-style page can remain usable on mobile and desktop by giving the body a max-width of 1200px and margin: 0 auto. Moving the background color to html prevents white side bands on wider screens. section 4.5.3

Listing 4.15 Changes to the body and html elements
html { background-color: #f9f7f1 }
 
body {
  background-color: #f9f7f1;       ①
  font-family: 'PT Serif', serif;
  color: #404040;
  padding: 0 24px;
  max-width: 1200px;               ②
  margin: 0 auto;                  ③
}#1 Moves the background color from the body rule to the html rule
#2 Sets the maximum width our page can become
#3 Centers the page

Inspect the compact CSS changes that limit the page width, center the body, and preserve the full-page background. section 4.5.3

How Tiny CSS Projects covers it

How deep it goes
Builds layouts incrementally from narrow screens, covering Grid, Flexbox, media queries, max-width, and centering without formal theory.
Examples
Uses a responsive newspaper, summary cards, checkout table, and flipping virtual credit card as concrete layout projects.
What you can do after
Apply CSS Grid, Flexbox, media queries, max-width, and automatic margins to build responsive page layouts.
How it connects
Connects layout with CSS Grid, Flexbox, media queries, responsive design, positioning, and background sizing.

Also explained in

Compare how 7 books explain layout →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny CSS Projects. The section links point to the parts of the book it draws on.