freecoding.school100% FREE · NO SIGNUP
Grid CanyonISSUE #16 of 27

grid container · template-columns · template-rows

FlexboVSThe Float Phantom
Flexbo saysgrid-template-columns and -rows define track sizes, with the fr unit and repeat().

grid-template-columns: 1fr 2fr makes two columns sharing space 1:2. The fr unit is a fraction of free space. repeat(3, 1fr) is shorthand for three equal columns, and minmax(200px, 1fr) sets a floor and ceiling — the building blocks of responsive grids.

Power-ups you unlock

The Float Phantom attacks — common mistakes

Boss battleBuild a layout with a 200px sidebar and a 1fr main using grid-template-columns.

Example code

<!doctype html><html><head><meta charset="utf-8">
<style>.g{display:grid;grid-template-columns:200px 1fr;gap:10px}.g div{color:#e6e0ff;padding:16px}.s{background:#1c1240}.m{background:#140a28}</style></head><body style="background:#06040d;padding:20px"><div class="g"><div class="s">200px</div><div class="m">1fr main</div></div></body></html>
▶ Open the interactive comic issue
‹ Grid · The Two-Dimensional LayoutGrid Container · Gap · Auto-Rows ›