how css grid changes everythingw3c developer meetup @jensimmons follow @jensimmons for slides layout...

134
How CSS Grid Changes Everything (in 15 mins?) W3C Developer Meetup @jenSimmons

Upload: others

Post on 16-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

How CSS Grid Changes Everything

(in 15 mins?)

W3C Developer Meetup @jenSimmons

Page 2: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Follow @jensimmons

for slides

Page 3: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Layout on the Web

Page 4: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 5: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 6: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 7: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 8: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 9: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 10: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 11: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 12: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 13: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 14: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 15: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 16: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 17: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 18: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 19: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 20: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 21: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 22: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 23: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

photo by Brad Frost, 2012, CC BY 2.0

Page 24: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 25: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 26: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 27: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 28: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

The Official Timeline of Web Page Layout

The No-Layout

LayoutTable-based

LayoutsHand -coded Float Layouts

Framework Layouts Amazing

Future!

Page 29: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

CSS Grid

Flexbox

Alignment

Writing Modes

Multicolumn

Viewport Units

Transforms

Object Fit

Clip-path

Masking

Shape-outside

Initial-letter

Flow

Floats

Block

Inline

Inline-block

Display:table

Margin

Negative margins

Padding

everything else

in CSS

Page 30: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

This new CSS changes everything in web layout.

Page 31: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

labs.jensimmons.com

Page 32: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 33: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 34: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 35: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Grid makes it much easier to implement

the same old layouts.

Page 36: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Grid makes it possible to do layouts that were

not possible before.

Page 37: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Nature of CSS Grid

Page 38: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

explicit vs. implicit

Page 39: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

You define !e size and/or number of rows and/or columns

Let !e browser define number or

size of rows or columns

Page 40: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

P lace each "em into a specific cell or area

Let !e browser place each "em using

auto-placement algor"hm

Page 41: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Rows *and* Columns

Page 42: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

ROWS!!!!!!!!!!!

Page 43: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 44: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 45: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Tracks don’t have to all be the same size.

Page 46: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 47: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 48: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Content sized by the size of a track.

Page 49: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Tracks sized by the size of content.

Page 50: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

portion of available space — 2 parts

set by content size

fixed portion of available space —  1 part

Page 51: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Grid Code

Page 52: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 53: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 54: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Grid Container

Page 55: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Grid Items

Page 56: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

<body> <header>…</header> <main> <article> <h1> <p> <p> <p> <figure> <p> </article> </main> <aside>…</aside> <footer>…</footer> </body>

body { display: grid; }

Page 57: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

<body> <header>…</header> <main> <article> <h1> <p> <p> <p> <figure> <p> </article> </main> <aside>…</aside> <footer>…</footer> </body>

body { display: grid; }

article { display: grid; }

Page 58: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

<body> <header>…</header> <main> <article> <h1> <p> <p> <p> <figure> <p> </article> </main> <aside>…</aside> <footer>…</footer> </body>

body { display: grid; }

main { display: subgrid; }

article { display: subgrid; }

Page 59: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

<body> <header>…</header> <main> <article> <h1> <p> <p> <p> <figure> <p> </article> </main> <aside>…</aside> <footer>…</footer> </body>

body { display: grid; }

article { display: grid; }

Page 60: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Headline HereThis is teaser text. It comes in different lengths. Headline Here

This is teaser text. It comes in different lengths. Here we see more content filling the box up all the way.

HeadlineThis is teaser text.

Headline That is Longer & WrapsThis is teaser text. It comes in different lengths.

HeadlineThis HeadlineThis is teaser text. It comes in different lengths.

Page 61: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Headline HereThis is teaser text. It comes in different lengths. Headline Here

This is teaser text. It comes in different lengths. Here we see more content filling the box up all the way.

HeadlineThis is teaser text.

Headline That is Longer & WrapsThis is teaser text. It comes in different lengths.

HeadlineThis HeadlineThis is teaser text. It comes in different lengths.

Page 62: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Headline HereThis is teaser text. It comes in different lengths. Headline Here

This is teaser text. It comes in different lengths. Here we see more content filling the box up all the way.

HeadlineThis is teaser text.

Headline That is Longer & WrapsThis is teaser text. It comes in different lengths.

HeadlineThis HeadlineThis is teaser text. It comes in different lengths.

Page 63: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Headline HereThis is teaser text. It comes in different lengths. Headline Here

This is teaser text. It comes in different lengths. Here we see more content filling the box up all the way.

HeadlineThis is teaser text.

Headline That is Longer & WrapsThis is teaser text. It comes in different lengths.

HeadlineThis HeadlineThis is teaser text. It comes in different lengths.

Page 64: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Headline HereThis is teaser text. It comes in different lengths. Headline Here

This is teaser text. It comes in different lengths. Here we see more content filling the box up all the way.

HeadlineThis is teaser text.

Headline That is Longer & WrapsThis is teaser text. It comes in different lengths.

HeadlineThis HeadlineThis is teaser text. It comes in different lengths.

Page 65: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

labs.jensimmons.com

Page 66: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Container

Item Item Item

Page 67: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Terminology

Page 68: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Grid Container

Page 69: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Grid Items

Page 70: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Grid Line

Grid Track

Grid

Tra

ck Grid Line

Grid Line

Grid Line

Grid Line

Grid Area

Grid Cell

Page 71: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Grid LineG

rid T

rack Grid Line

Grid Line

Grid Line

Grid Line

Grid Gap

Grid Gap

Grid Gap

Grid Track

Page 72: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

4 Examples

Page 73: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

labs.jensimmons.com/2017/01-003.html

Page 74: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 75: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

<ul> <li><img src="/file1.jpg" ></li> <li><img src="/file2.jpg" ></li> <li><img src="/file3.jpg" ></li> <li><img src="/file4.jpg" ></li> <li><img src="/file5.jpg" ></li> <li><img src="/file6.jpg" ></li> <li><img src="/file7.jpg" ></li> </ul>

Page 76: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

ul { display: grid; grid-template-columns: repeat(4, 100px); grid-gap: 4px; } li { // nothing }

Page 77: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

ul { display: grid; grid-template-columns: repeat(4, 100px); grid-gap: 4px; }

li { // nothing }

Page 78: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

ul { display: grid; grid-template-columns: repeat(4, 100px); grid-gap: 4px; } /* or */ ul { display: grid; grid-template-columns: 100px 100px 100px 100px; grid-gap: 4px; }

Page 79: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 80: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

ul { display: grid; grid-template-columns: repeat(5, 1fr); grid-gap: 0.25em; }

/* or */ ul { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr 1fr; grid-gap: 0.25em; }

Page 81: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 82: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

ul { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); grid-gap: 0.25rem; }

Page 83: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 84: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 85: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

nightly.mozilla.org

Page 86: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

ul { display: grid; grid-template-columns: repeat(4, 1fr); }

Page 87: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

li:nth-child(1) { grid-column: 2 / 3; grid-row: 1 / 2; }

Page 88: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

li:nth-child(1) { grid-column: 2 / 3; grid-row: 1 / 2; } li:nth-child(2) { grid-column: 4 / 5; grid-row: 2 / 3; } li:nth-child(3) { grid-column: 3 / 4; grid-row: 3 / 4; } li:nth-child(4) {…} li:nth-child(5) {…}

Page 89: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

‘fr ’ unit

Page 90: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

.grid-container { display: grid; grid-template-columns: 1fr 1fr 1fr; }

some other syntax options (each with different results)

grid-template-columns: 1fr 5fr 2.5fr;

grid-template-columns: 8em 1fr 300px;

grid-template-columns: 1fr 1fr 2fr 3fr 5fr 8fr 13fr 21fr 34fr;

grid-template-columns: repeat(7, 1fr);

grid-template-columns: repeat(3, 200px 1fr 25%);

grid-template-columns: repeat(auto-fill, 10rem);

grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));

grid-template-columns: 4rem 2fr repeat(5, 1fr) 300px;

Page 91: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

px

em

%

pixels

(or rem)

percents

60px

10em

20%

Page 92: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

min-content

max-content

fr

minmax()

Page 93: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

fr unit = “fraction”

Page 94: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 95: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

100%

33% 33% 33%

Page 96: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

100%

33.33333% 33.33333% 33.33333%

Page 97: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

100%

33.33333% 33.33333% 33.33333%

Page 98: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

100%

33% 33% 33%

2% 2%

Page 99: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

100%

32% 32% 32%

2% 2%

100% – 4% = 96% = 32% 3 3

Page 100: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

100%

31.333% 31.333% 31.333%

3% 3%

100% – 6% = 94% = 31.333% 3 3

Page 101: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

100%

31.666% 31.666% 31.666%

2.5% 2.5%

100% – 5% = 95% = 31.666666666666666% 3 3

Page 102: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

.box { width: calc(100-(2*2em)/3)%;}

100%

x% x% x%

2em 2em

@media (min-width: 600px) { .box { width: calc(100-(2*2em)/3)%;}}@media (min-width: 800px) { .box { width: calc(100-(3*2em)/4)%;}}@media (min-width: 1000px) { .box { width: calc(100-(4*2em)/5)%;}}

@media (min-width: 400px) { .box { width: calc(100-(1*2em)/2)%;}}

Page 103: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

100%

1fr 1fr 1fr

2em 2em

Page 104: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

1fr 1fr 1fr

2em 2em

1fr + 1fr + 1fr = 3fr total

therefore, 1fr = 1/3 of the space

Page 105: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

1fr 1fr 1fr

2em 2em

1fr + 1fr + 1fr + 1fr = 4fr total

therefore, now 1fr = 1/4 of the space

1fr

2em

Page 106: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

100px 1fr 1fr

1fr 1fr100px

Page 107: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

2fr 1fr50px 1fr min-content

Page 108: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

6fr 2.4fr1fr 2.4fr 2fr

Page 109: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

What about old browsers?

Page 110: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 111: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

6

Page 112: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 113: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

You must support browsers that

do not understand CSS Grid.

Page 114: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

@supports (foo: value) { // some CSS code here }

Page 115: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

// code for non-Grid browsers

@supports (display: grid) { // undo some of the above // then do your Grid layout }

Page 116: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

hacks.mozilla.org/2016/08/using-feature-queries-in-css

Page 117: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 118: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

6

Page 119: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

You have two choices for Internet Explorer (& old Edge):

1) Leverage the 2012 Grid implementation.

2) Pretend IE has no Grid.

Page 120: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

You have two choices for Internet Explorer (& old Edge):

1) Use old -ms-* syntax.

2) Or don’t.

Page 121: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

display: grid; grid-template-columns: repeat(4, 100px);

display: -ms-grid; -ms-grid-columns: (100px)[4];

Page 122: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Autoprefixer

Page 123: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 124: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

rachelandrew.co.uk/archives/2016/11/26/should-i-try-to-use-the-ie-implementation-of-css-grid-layout

Page 125: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 126: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 127: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 128: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 129: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page
Page 130: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

For more…

Page 131: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

jensimmons.com/post/feb-27-2017/learn-css-grid

Page 132: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

developer.mozilla.org/docs/Web/CSS/CSS_Grid_Layout

Page 133: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

Modern Layouts: Getting Out of Our Ruts

Revolutionize Your Page: Real Art Direction on the Web

2015

2016

available on jensimmons.com

Page 134: How CSS Grid Changes EverythingW3C Developer Meetup @jenSimmons Follow @jensimmons for slides Layout on the Web photo by Brad Frost, 2012, CC BY 2.0 The Official Timeline of Web Page

jensimmons.com @jensimmons layout.land labs.jensimmons.com

Thanks!