slides.oddbird.net/rws/smashing/grids/

Defining Structure

slides.oddbird.net/rws/smashing/grids/

@ Smashing Online

(╯'□')╯︵ ┻━┻
TABLES ARE FOR DATA

00s… Float: Everything

watch out for the double-margin bug!

2007-2010… Major Grid Frameworks

Blueprint, OOCSS, 960gs, Susy, etc…

grid item with margin on the right side to form a gutter

2010… Responsive Web Design

.grid-span {
width: percentage( /* 23.7288136% */
((3 * 4em) + (2 * 1em)) / ((12 * 4em) + (11 * 1em))
);
margin-right: percentage( /* 01.6949153% */
1em / ((12 * 4em) + (11 * 1em))
);
padding-left: percentage( /* 08.4745763% */
((1 * 4em) + (1 * 1em)) / ((12 * 4em) + (11 * 1em))
);
}

(╯'□')╯︵ ┻━┻
FLOATS ARE FOR

Avoid Explicit Widths

Flexbox is an implicit system

Designed to Pair With CSS Grid

oops, five years later…

2017… CSS Grid

March 6-9: Firefox 52 & Chrome 57

Modern Web Is Evergreen

new features over the weekend

Explicit (2D) Layouts! With Rows & Columns

Explicit Layouts! Defined by the Container

Explicit Layouts! With Intrinsic Options

  1. Fluid & Fixed
  2. Stages of Squishiness
  3. Truly Two-Dimensional Layouts
  4. Nested Contexts
  5. Expand & Contract Content
  6. Media Queries, As Needed

Implicit grids

generate auto-columns/rows as needed

Explicit grids

generate columns/rows from a template

grid-auto-flow: row

column | [+ dense]

Item Placement grid-column-start: auto
grid-column-end: auto

Item Placement grid-column: <start> / <end>
grid-row: <start> / <end>

Item Span grid-column: span <count>

either start or end can be a span

Grid Terminology

lines, row & column tracks, cells, and areas

Sizing Implicit Tracks grid-auto-columns
grid-auto-rows

Defining Templates grid-template-columns
grid-template-rows

& Intrinsic min-content 20% max-content

& Fitted fit-content(<limit>)

clamp(auto, max-content, <limit>)

  • % ➡ relative to parent width
  • vw ➡ relative to viewport width
  • fr ➡ relative to leftover space

1fr of 1000px Depends on Leftover Space

  • pxFixed
  • emRelative
  • vwRelative
  • %Fluid
  • frFlexible
  • px<length>
  • em<length>
  • vw<length>
  • %<length>
  • fr<flex>

Except all fr tracks Have A Minimum As Well

Flexible Until Fixed minmax(20em, 1fr)

(only use fr for max value)

🤯 What is Leftover On an infinite Axis?

Stages of Squishiness Auto ➡ Minmax Flex

grid-template-areas

'header header header'
'nav main aside'
'nav footer aside';

grid-template:

<areas-rows> / <columns>

grid-template

  'header          header         header' auto
'nav main aside' 1fr
'nav footer aside' auto
/ fit-content(20%) minmax(0, 1fr) 20em

Area Start & End grid-row: header / footer

<r-start> / <c-start> /
<r-end> / <c-end>
header / main /
main / aside

Generated Line Names header-start / main-end

Named Grid Lines

[before] 1fr [center] 1fr [after]

Align to Names

grid-column: before / after ;

Names Areas

with matching *-start & *-end names

[nav-start] 15em [nav-end] grid-area: nav

Overlapping Areas

[full-start nav-start] 20em [nav-end] 1fr [full-end]

grid-template

               'header          header         header' auto
'nav main aside' 1fr
'nav footer aside' auto
/ [full-start] fit-content(20%) minmax(0, 1fr) 20em [full-end]

Repeating Grids

repeat( <count>, <tracks> )

Fit Available Items

repeat( auto-fit , minmax( 15em, 1fr ));

Fill Available Space

repeat( auto-fill , 200px);

Subgrid

as column or row template

Masonry ???

as column or row template