Grid Fundamentals

Homework

  1. Review
  2. CSS Grid
  3. Fast Layouts

Morning reflection

Housekeeping

  1. CPNT 260 Assignment 3
  2. Dailies feedback
    • Decline in submissions for W3W?
    • Copy and paste is fine, but…
      • Try making something from scratch.
      • Add comments: problems, victories, questions.
    • body and head are not needed in Codepen.
    • Comment out broken code if something isn’t working and you need help with it.

Lecture/Live code

Learning Objectives

  • Discuss the differences between Flexbox and CSS Grid.
  • Identify the strengths and weaknesses of each technology.
  • Define a Grid template using traditional length units.
  • Define a Grid template using the fr unit.
  • Layout a web page with Grid names and areas.

Terms

Materials

General implementation process

  1. Define your container. All direct children will become grid items.
  2. Define your Grid template.
  3. Explicitly place items, if needed.

Key Takeaways

  • Like Flexbox, Grid items are defined as the direct children of the container.
  • Flexbox vs Grid: Flex operates in one direction like a sentence (in row direction) and Grid operates in two dimensions like a spreadsheet.
  • Unlike Flexbox, grids don’t change axis; columns are always in the up-down direction and rows are left-right.
  • The grid template is not a part of the DOM. It cannot by styled or targetted with selectors. Its purpose is to guide the positioning of the grid items.
  • Implicit item placement happens automatically: the browser will place items on the grid in source order. You can control this with various explicit placement properties.
  • Grid cells cannot take non-rectangular shapes (like a Tetris “L”). They must be rectangular.
  • Half the grid declarations seem to be shorthand properties.

Open lab-time

Tips for learning

Tony’s goals


Activities

  1. MDN: Test your skils: Grid Layout
  2. Free Code Camp: Grid challenges
  3. Layout challenges: try using Grid to duplicate the following layouts:

Dailies

  • Submit today’s Codepen/repo/gist to the Dailies section (in Assessments) in Brightspace.