3 CSS Grid Layouts That You'll Ever Need

  • CSS
  • Grid
  • Layout

Responsive without Media Queries

The Problem?

Building a responsive layout requires media queries. This adds complexity and maintenance overhead.

The Solution!

CSS Grid allows you to create responsive layouts without media queries using the repeat(auto-fit) function.

Card 1 Card 2 Card 3

Holy Grail

The Problem?

Building a classic application layout (Header, Sidebar, Main Content, Footer) is historically painful. You have to deal with float, flex-direction, or fixed positioning. If the sidebar height changes, the footer breaks.

The Solution!

CSS Grid allows you to draw your layout using ASCII-style names. It is self-documenting code.

Header
Main
Footer

Holy Grail with a Twist

The Problem?

What if you want the sidebar to be on the right on desktop, but on the left on mobile? With traditional CSS, you would need to duplicate your HTML or use JavaScript to change the order of elements.

The Solution!

CSS Grid allows you to change the order of elements using the grid-template-areas property. You can define different layouts for different screen sizes without changing your HTML.

Header
Main
Footer

Full Bleed

The Problem?

Blog copy should stay readable in a centred column, but media and code examples sometimes need to stretch edge-to-edge.

The Solution!

Use a three-column grid with gutters and a middle content track. Place everything in the middle by default, then let selected items (like img.full-width) span from the first to the last grid line.

The centre column holds your primary reading flow at a comfortable line length.

Demonstration image spanning the full bleed width

After the full-bleed element, content drops back into the middle track so the reading flow stays clear and comfortable.