Slide 1

Slide 1 text

Progressing Our Layouts Jen Simmons @jensimmons thewebahead.net

Slide 2

Slide 2 text

Amazing future! The No-layout Layout Table-based Layouts Float-based Layouts The Official Timeline of the Evolution of Web Page Layout

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

(*Tweets in response, with names removed to protect the, well, not the innocent, but to protect people from trolling.)

Slide 5

Slide 5 text

Works Doesn’t work

Slide 6

Slide 6 text

Use It Don’t Use It

Slide 7

Slide 7 text

Works Doesn’t work Use It Don’t Use It

Slide 8

Slide 8 text

Works Doesn’t work Use It Don’t Use It

Slide 9

Slide 9 text

Works Doesn’t work Use It Don’t Use It

Slide 10

Slide 10 text

Works Doesn’t work Use It Don’t Use It Fired.

Slide 11

Slide 11 text

Works Doesn’t work Use It Don’t Use It Fired.

Slide 12

Slide 12 text

Works Doesn’t work Use It Don’t Use It Fired. ✔

Slide 13

Slide 13 text

Works Doesn’t work Use It Don’t Use It

Slide 14

Slide 14 text

Works and Doesn’t Work Use It and Don’t Use It Don’t Use It

Slide 15

Slide 15 text

Works and Doesn’t Work Use It and Don’t Use It Don’t Use It X

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

drawing by Dave Ellis novolume.co.uk

Slide 18

Slide 18 text

So, ok, how?

Slide 19

Slide 19 text

This Thing About CSS

Slide 20

Slide 20 text

.box { background: #bbb; border: 10px solid black; border-radius: 50px; }

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

.box { background: #bbb; border: 10px solid black; border-radius: 50px; }

Slide 24

Slide 24 text

.box { background: #bbb; border: 10px solid black; border-radius: 50px; } .box { background: #bbb; border: 10px solid black; border-radius: 50px; } Opera Mini IE8 IE7 IE6 Firefox Safari Chrome IE9+ Edge (on all operating systems)

Slide 25

Slide 25 text

That Magic Thing Where “Weird Stuff” Gets Ignored

Slide 26

Slide 26 text

CSS Shapes

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

img { width: 200px; margin: 0 1.5em 0.5em 0; float: left; shape-outside: circle(); } There is a prefix: -webkit-shape-outside: circle(); *

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

img { width: 200px; margin: 0 1.5em 0.5em 0; float: left; shape-outside: circle(); } There is a prefix: -webkit-shape-outside: circle(); *

Slide 31

Slide 31 text

img.grapes { max-width: 600px; float: left; margin-left: -26%; shape-outside:polygon( nonzero, -69.6% 101.25%, -84.35% 24.5%, 1.65% 4%, 23.3% 14.25%, 40.4% 13.5%, 43% 13.25%, 57.1% 16.5%, 62.7% 27%, 74.5% 32.25%, 78.15% 42.5%, 80.1% 49.25%, 77.15% 58.75%, 92.25% 68.25%, 92.9% 82.25%, 75.5% 92.5%, 51.55% 90.75%, -5.6% 101.25% ); }

Slide 32

Slide 32 text

img.grapes { max-width: 600px; float: left; margin-left: -26%; shape-outside:polygon( nonzero, -69.6% 101.25%, -84.35% 24.5%, 1.65% 4%, 23.3% 14.25%, 40.4% 13.5%, 43% 13.25%, 57.1% 16.5%, 62.7% 27%, 74.5% 32.25%, 78.15% 42.5%, 80.1% 49.25%, 77.15% 58.75%, 92.25% 68.25%, 92.9% 82.25%, 75.5% 92.5%, 51.55% 90.75%, -5.6% 101.25% ); }

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

labs.jensimmons.com @jensimmons

Slide 35

Slide 35 text

Tool #1: CSS Error Handling

Slide 36

Slide 36 text

Viewport Units + Flexbox

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

header { display: flex; height: 100vh; } h1 { margin: auto; }

Slide 40

Slide 40 text

header { display: flex; height: 100vh; } h1 { margin: auto; }

Slide 41

Slide 41 text

header { display: flex; height: 500px; height: 100vh; } h1 { margin: auto; }

Slide 42

Slide 42 text

header { display: flex; height: 500px; height: 100vh; } h1 { margin: auto; }

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

header { display: flex; height: 500px; height: 100vh; } h1 { margin: auto; }

Slide 45

Slide 45 text

header { display: flex; height: 500px; height: 100vh; } h1 { margin-top: 2em; margin: auto; }

Slide 46

Slide 46 text

header { display: flex; height: 500px; height: 100vh; } h1 { padding: 2em 0; margin: auto; }

Slide 47

Slide 47 text

header { display: flex; height: 500px; height: 100vh; } h1 { padding: 2em 0; margin: auto; }

Slide 48

Slide 48 text

header { display: flex; height: 500px; height: 100vh; } h1 { padding: 2em 0; margin: auto; } The running code uses prefixes, which I’ll talk about later. *

Slide 49

Slide 49 text

Tool #2: CSS Overrides

Slide 50

Slide 50 text

Initial Letter

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

p::first-letter { color: rgba(255,190,150,0.9); font-weight: bold; margin-right: 0.5em; -webkit-initial-letter: 4; initial-letter: 4; }

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

Safari 9 (iOS and Mac OSX)

Slide 56

Slide 56 text

p::first-letter { color: rgba(255,190,150,0.9); font-weight: bold; margin-right: 0.5em; -webkit-initial-letter: 4; initial-letter: 4; }

Slide 57

Slide 57 text

p::first-letter { color: rgba(255,190,150,0.9); font-weight: bold; margin-right: 0.5em; -webkit-initial-letter: 4; initial-letter: 4; }

Slide 58

Slide 58 text

@supports (initial-letter: 4 ) or (-webkit-initial-letter: 4 ) p::first-letter { color: rgba(255,190,150,0.9); font-weight: bold; margin-right: 0.5em; -webkit-initial-letter: 4; initial-letter: 4; } }

Slide 59

Slide 59 text

Tool #3: @supports, aka Feature Queries

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

@supports (initial-letter: 4 ) or (-webkit-initial-letter: 4 ) p {color:red;} p::first-letter { color: rgba(255,190,150,0.9); font-weight: bold; margin-right: 0.5em; -webkit-initial-letter: 4; initial-letter: 4; } }

Slide 62

Slide 62 text

// Layout overrides for browsers that // don't support Flexbox flex-wrap, // namely, Firefox 25 to 28. @supports (not (flex-wrap: wrap)) { .article-list { display: block; } article { flex: none; float: left; width: 48%; } }

Slide 63

Slide 63 text

Tool #3: @supports, aka Feature Queries

Slide 64

Slide 64 text

Prefixes

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

Bonus Tool: Autoprefixer

Slide 69

Slide 69 text

Tool #4: Modernizer

Slide 70

Slide 70 text

modernizer.com

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

.flexwrap { // // the flexbox layout // // } .no-flexwrap { // // the old school layout // // }

Slide 73

Slide 73 text

Tool #5: Conditional Stylesheets

Slide 74

Slide 74 text

Tool #0: Conditional Stylesheets

Slide 75

Slide 75 text

Slide 76

Slide 76 text

Slide 77

Slide 77 text

@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) { // IE10+ CSS here }

Slide 78

Slide 78 text

Tool #6: Polyfill

Slide 79

Slide 79 text

Grid

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

No content

Slide 86

Slide 86 text

No content

Slide 87

Slide 87 text

ul { display: grid; grid-template-columns: repeat(2, 1fr); grid-auto-rows: 50vw; grid-auto-flow: dense; @media (min-width: 360px) { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 33vw; } @media (min-width: 500px) { grid-template-columns: repeat(4, 1fr); grid-auto-rows: 25vw; } @media (min-width: 700px) { grid-template-columns: repeat(5, 1fr); grid-auto-rows: 20vw; } @media (min-width: 900px) { li { height: 100%; border: 1px solid black; } li.highlight-box { grid-row: span 2; grid-column: span 2; } li.highlight-tall { grid-row: span 2; } li.highlight-wide { grid-column: span 2; } img { display: block; object-fit: cover; height: 100%; }

Slide 88

Slide 88 text

labs.jensimmons.com

Slide 89

Slide 89 text

No content

Slide 90

Slide 90 text

1. Fact CSS ignores code it doesn’t recognize 2. The CSS Cascade 3. Feature Queries with @supports { } 4. Modernizer 5. Conditional Stylesheets for IE 6. Polyfills

Slide 91

Slide 91 text

¿ ? What are we going to do about full-page layout?

Slide 92

Slide 92 text

Don’t use Grid 
 until 100% of your audience has it

Slide 93

Slide 93 text

Write float-based 
 (inline block / display table) layout & deliver that to some browsers, while the rest 
 get Grid layout

Slide 94

Slide 94 text

(You should NOT be jacking up the HTML order for layout anyway, so the HMTL for both will be identical.)

Slide 95

Slide 95 text

Deliver a “mobile” / skinny / simplified layout to older browsers, and a full-page Grid layout to supporting browsers

Slide 96

Slide 96 text

No content

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

Use a Polyfill for Grid

Slide 99

Slide 99 text

No content

Slide 100

Slide 100 text

No content

Slide 101

Slide 101 text

No content

Slide 102

Slide 102 text

Use a Polyfill for Grid

Slide 103

Slide 103 text

Basic layout, that doesn’t require Grid. Or Media Queries. Or Feature Queries. Hand-write your own CSS for this. Drop layout frameworks & learn vanilla CSS.

Slide 104

Slide 104 text

Basic layout, that doesn’t require Grid. Or Media Queries. Or Feature Queries. Hand-write your own CSS for this. Drop layout frameworks & learn vanilla CSS. Code that uses Grid to create the layout. Use Feature Queries to hide it from non-supporting browsers.

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

Thanks! labs.jensimmons.com @jensimmons thewebahead.net