The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated...

83
The Evolution of Responsive Design RACHEL ANDREW AT FRONT END NORTH 2020

Transcript of The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated...

Page 1: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

The Evolution of Responsive Design

RACHEL ANDREW AT FRONT END NORTH 2020

Page 2: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

How do we support all these different screen sizes?

Page 3: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:
Page 4: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Fluid Gridshttps://alistapart.com/article/fluidgrids/

Page 5: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:
Page 6: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:
Page 7: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

target ÷ context = result

Page 8: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Flexible Imageshttps://alistapart.com/article/fluid-images/

Page 9: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

max-width: 100%

Page 10: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Media QueriesHow big is this viewport?

Page 11: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Responsive Web Design

• Calculating percentages for floated layouts• Squishing images• Leaning on Media Queries

Page 12: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

column-count: 3

Page 13: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Flexbox responds to the content

Page 14: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

display: flex

Page 15: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

display: flex

Page 16: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Flexbox is one-dimensional

Page 17: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

flex-wrap: wrap

Page 18: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

flex: 0 0 32%

Page 19: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

What does it mean to respond to content?

Page 20: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

flex-basis: auto

max-content

Page 21: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

flex-basis: auto

Space reduced from max-content until all boxes fit

Page 22: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

We don’t have to line everything up.Sometimes what we need is just to make things fit nicely.

Page 23: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

CSS GridFor when you do want to line everything up.

Page 24: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

.grid {display: grid;grid-template-columns: repeat(12, 1fr);

}

Page 25: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

repeat(12, 1fr)

Page 26: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

.grid {display: grid;grid-template-columns:repeat(12, minmax(auto, 1fr));

}

Page 27: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

repeat(12, 1fr)

Page 28: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

.grid {display: grid;grid-template-columns:repeat(12, minmax(0, 1fr));

}

Page 29: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

repeat(12, minmax(0,1fr))

Page 30: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Responding to content in a grid layout world

Page 31: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

auto

Page 32: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

grid-template-columns: repeat(3, auto)

Page 33: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

justify-content: start

Page 34: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

repeat(12, 1fr)

Page 35: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

flex-basis: auto

repeat(3, 1fr)

Page 36: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

min-content, max-content, fit-contentDirecting content-based sizing

Page 37: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

repeat(3, min-content)

Page 38: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

repeat(3, max-content)

Page 39: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

repeat(3, fit-content(400px))

max-content 400px

Page 40: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

.media {

display: grid;

grid-template-columns: fit-content(300px) 1fr;

gap: 20px;

}

Page 41: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:
Page 42: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Flexible imagesMore than just max-width: 100%

Page 43: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Responsive Images

Page 44: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Solving the janky images problemMapping HTML attributes width and height to an aspect ratio.

Page 45: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

It’s time to start using the width and height attributes on the <img> element again

Page 46: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:
Page 47: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Media Queries

Page 48: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

column-width: 200px

Page 49: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

flex-wrap: wrap

Page 50: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

repeat(auto-fill, minmax(200px, 1fr)

Page 51: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

The first rule of Media Queries is …Do I need a media query?

Page 52: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

.wrapper {

display: grid;

grid-template-areas:

"hd"

"bd"

"sd"

"ft";

}

Page 53: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:
Page 54: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

@media (min-width: 600px) {

.wrapper {

grid-template-columns: 3fr 1fr;

grid-template-areas:

"hd hd"

"bd sd"

"ft ft";

}

}

Page 55: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:
Page 56: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

More than just screen sizeWhat else could we respond to?

Page 57: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

What type of pointer do I have?

Page 58: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

@media (pointer:coarse) {

.pointer::before {

content: "You have a coarse pointer";

}

}

@media (pointer:fine) {

.pointer::before {

content: "You have a fine pointer";

}

}

Page 59: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Can I hover?

Page 60: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

@media (hover) {

.can-i-hover::after {

content: "You look like you can hover.";

}

}

@media (hover:none) {

.can-i-hover::after {

content: "I don't think you can hover.";

}

}

Page 61: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

@media (any-pointer:coarse) {

.any-pointer::before {

content: "One of your pointers is coarse. Your device has a touchscreen, though you might notbe using it.";

}

}

Page 62: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:
Page 63: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

“Designing a page that relies on hovering or accurate pointing only because any-hover or any-pointer indicate that at least one of the available input mechanisms has these capabilities is likely to result in a poor experience.

Media Queries Level 4https://drafts.csswg.org/mediaqueries-4/#any-input

Page 64: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Testing capabilities Check for screen size, but also pointer type and hover ability to understand the environment your site is being used in.

Page 65: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Overflow detectionDisplay Quality Media Queries

Page 66: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

@media (overflow-block: paged) {

/* CSS for paged media */

}

Page 67: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Responding to the wishes of the visitorMedia Queries Level 5 and User Preference Media Features

Page 68: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

prefers-reduced-motion

Page 69: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

@media (prefers-reduced-motion: reduce) {

.animation {

animation: none;

}

}

Page 70: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

prefers-color-scheme

Page 71: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

@media (prefers-color-scheme: dark) {

body {

background: #333;

color: white;

}

}

Page 72: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

prefers-reduced-data

Page 73: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

@media (prefers-reduced-data: reduce) {

/* CSS loading in smaller images */

}

Page 74: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Feature QueriesWhat does this browser support?

Page 75: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

@supports (display: grid) {

.grid {

display: grid;

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

}

}

Page 76: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

What does it mean to do responsive design today?

Page 77: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Respond to content

Page 78: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Use new layout and image features

Page 79: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Use media features toenhance your site.

Page 80: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

It’s not about screen size

Page 81: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Responding to needs and environment

Page 82: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Stop expecting people to fixsomething to use your website. Respond to meetthem where they are.

Page 83: The Evolution of Responsive Design · Responsive Web Design • Calculating percentages for floated layouts ... Responding to content in a grid layout world. auto. grid-template-columns:

Thank you!https://noti.st/rachelandrew