flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · flexbox float 2,589...

72
Flexbox for fun and profit

Upload: others

Post on 19-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Flexbox for fun and profit

Page 2: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

@charlieparkhi!

Page 3: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

@charlieparkfront-end engineer

hi!

IFTTT

Page 4: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

@charlieparkfront-end engineer

hi!

Page 5: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 6: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Flexbox

Page 7: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Today

• what is flexbox? • a brief history of <me layout on the web • right, so, what is flexbox, really? - syntax - mnemonics for tricky bits - browser support? - performance benefits • what can flexbox do? examples plz? • ques<ons!

Page 8: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 9: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

What is flexbox?

Page 10: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

display: flex;

Page 11: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 12: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 13: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 14: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

1990

Page 15: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 16: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 17: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

1994

Page 18: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 19: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 20: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

But, Charlie, why do we care about this?

Page 21: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

1999

2001

2003

Page 22: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 23: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Everything is unpredictable.

Page 24: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Everything is unpredictable.• content

Page 25: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Everything is unpredictable.• content• context

Page 26: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Flexbox to the rescue

Page 27: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 28: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 29: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 30: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 31: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 32: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 33: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 34: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 35: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 36: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 37: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 38: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 39: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 40: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 41: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 42: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Simple rules that the browser

intelligently interprets.

Page 43: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Container Children

Space

Page 44: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Direc<on Alignment

Order Flexibility

Page 45: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Direc<on

Page 46: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Alignment

Page 47: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Order

C

B

A

D

D

A

C

B

Page 48: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Flexibility

Page 49: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Examples soon!First, a few notes on migra<ng / support.

Page 50: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

yes** `-webkit-` prefix for a bit longer * Autoprefixer, Modernizr

Page 51: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

github.com/philipwalton/flexbugs

Page 52: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

modernizr.com

Page 53: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

autoprefixer.github.io/

Page 54: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 55: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Flexbox + Performance

Page 56: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 57: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

FlexboxFloat

1,458 1,121

23%

Page 58: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Flexbox

Float

2,589

42%

1,172

1,500 700

40%

Page 59: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 60: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Be_er for users, not on ini<al page load, but when scrolling, resizing the page, and loading remote content.

Page 61: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Example <me!

Page 62: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Syntax

display: flex flex-direc<on (row)

jus<fy-content (flex-start) align-items (stretch) flex-wrap (nowrap)

flex-grow (0) flex-shrink (1)

flex-basis (auto) order (1)

Page 63: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Mnemonics!jus<fy-content vs. align-items

???

Page 64: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

flex-direc<on: row

main-axis: lec to right cross-axis: top to bo_om

Page 65: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

flex-direc<on: column

main-axis: top to bo_om cross-axis: lec to right

Page 66: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 67: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 68: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,
Page 69: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

main-axis = jus<fy-content

Page 70: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Resources for more

Solved by Flexbox (Philip Walton)

CSS Tricks

Joni Trythall

Zoe Gillenwater

Wes Bos

Page 71: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

Thank you!

Page 72: Flexbox for fun and profitenvironmentsforhumans.com/2015/css-dev-conf/... · Flexbox Float 2,589 42% 1,172 1,500 700 40%. Be_er for users, not on inial page load, but when scrolling,

h_ps://www.flickr.com/photos/grabka/530562572/

h_ps://www.flickr.com/photos/kanriah/5147558884

h_ps://www.flickr.com/photos/soldiersmediacenter/3614744146

h_ps://www.flickr.com/photos/lionya/7879468818

h_ps://www.flickr.com/photos/davidstanleytravel/14437232405