65
FLEXBOX 1 CONTENT-DRIVEN LAYOUTS WITH

Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

Embed Size (px)

Citation preview

Page 1: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

FLEXBOX1

CONTENT-DRIVEN LAYOUTS WITH

Page 2: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

CHRIS SAUVE

2

Page 3: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

LAYOUT STRATEGIES

3

Page 4: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

ABSOLUTE POSITIONING

4

Page 5: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

INLINE BLOCK

5

Page 6: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

FLOATS

6

Page 7: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

THINK DIFFERENT

7

Page 8: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

CONTENT-OUT LAYOUT

8

Page 9: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

BROWSER SUPPORT

9

Page 10: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

YES YESYES10+ only-msinIE10

YESeveninMini!

10

Page 11: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

YES YESYES10+ only-msinIE10

YESeveninMini!CAN I USE SAYS…

95.44%11

Page 12: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

PARENT RULES

12

Page 13: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

display:flex;//orinline-flex

flex-direction:row;//orcolumn

13

Page 14: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

flex-direction:row;

14

Page 15: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1

2

3

flex-direction:column;

15

Page 16: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

display:flex;//orinline-flex

flex-direction:row;//orcolumn

16

Page 17: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

display:flex;//orinline-flex

flex-direction:row;//orcolumn

justify-content:center;

17

Page 18: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

Main Axis

justify-content

18

Page 19: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

justify-content:center;

19

Page 20: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

justify-content:flex-start;

20

Page 21: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

justify-content:flex-end;

21

Page 22: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

justify-content:space-between;

22

Page 23: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

justify-content:space-around;

23

Page 24: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

display:flex;//orinline-flex

flex-direction:row;//orcolumn

justify-content:center;

24

Page 25: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

display:flex;//orinline-flex

flex-direction:row;//orcolumn

justify-content:center;

align-items:stretch;

25

Page 26: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

Cross Axis

align-items

26

Page 27: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

align-items:stretch;//default

27

Page 28: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

align-items:center;

28

Page 29: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

align-items:flex-start;

29

Page 30: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

align-items:flex-end;

30

Page 31: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

display:flex;//orinline-flex

flex-direction:row;//orcolumn

align-items:stretch;

justify-content:center;

31

Page 32: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

display:flex;//orinline-flex

flex-direction:row;//orcolumn

align-items:stretch;

justify-content:center;

flex-wrap:nowrap;

32

Page 33: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

flex-wrap:nowrap;

33

Page 34: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2

3

flex-wrap:wrap;

34

Page 35: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

CHILD RULES

35

Page 36: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

flex-grow:0;

flex-shrink:0;

flex-basis:auto;

36

flex:<grow><shrink><basis>;

//or

Page 37: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

flex-basis:<length>;

flex-basis:auto;

width:<length>;

37

//roughlyequivalentto:

Page 38: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

100px

20px 20px 20px

38

Page 39: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

100px

20px 20px 20px

40px of “growth” available39

Page 40: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

flex-grow:0; flex-grow:0; flex-grow:0;

40

Page 41: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

flex-grow:1;

13px of growthflex-grow:1;

13px of growthflex-grow:1;

13px of growth

41

Page 42: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

flex-grow:1;

10px of growthflex-grow:2;

20px of growthflex-grow:1;

10px of growth

42

Page 43: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

flex-grow:0;

0px of growthflex-grow:1;

20px of growthflex-grow:1;

20px of growth

43

Page 44: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

40px

20px 20px 20px

44

Page 45: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

1 2 3

40px

20px 20px 20px

20px of “shrink” available45

Page 46: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

flex-shrink:0; flex-shrink:0; flex-shrink:0;

1 2 3

46

Page 47: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

flex-shrink:0; flex-shrink:1; flex-shrink:1;

1

0px of shrink 10px of shrink 10px of shrink

47

Page 48: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

NO SILVER BULLET

48

Page 49: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

AWESOME EXAMPLES

49

Page 50: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

PAGE LAYOUT

50

Play with the Codepencodepen.io/lemonmade/pen/RNEpJR?editors=110

Page 51: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

GOAL

51

Page 52: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

52

Header

ContentSidebar

Footer

GOAL

Page 53: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

SMART POPOVERS

53

Play with the Codepencodepen.io/lemonmade/pen/XJobem?editors=110

Page 54: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

54

Page 55: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

55

WRAPPABLE LAYOUTS

Play with the Codepencodepen.io/lemonmade/pen/XXWZBr?editors=110

Page 56: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

56

Page 57: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

REFLOWING HEADER

57

Play with the Codepencodepen.io/lemonmade/pen/ZYgNmy?editors=110

Page 58: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

58

Page 59: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

https://css-tricks.com/snippets/css/a-guide-to-flexbox/

CSS-TRICKS REFERENCE

59

Page 60: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

AUTOPREFIXER

https://github.com/philipwalton/flexbugs60

Page 61: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

FLEXBUGS

https://github.com/philipwalton/flexbugs61

Page 62: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

FLEXBOXFROGGY

http://flexboxfroggy.com62

Page 63: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

CHRIS SAUVE@_lemonmade

63

Page 64: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

SHOPIFYshopify.com/careers

64

Page 65: Content-Driven Layouts with Flexbox (Chris Sauve, CSSDay 2015)

THANKS EVERYONE!

65