Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Exploring Flexbox with Chris Sauvé

715 views

Published on

Achieving complex layouts in CSS has had a very checkered history. We escaped the tyranny of tables, but what we got wasn't much better — floats have had to be co-opted into roles for which they were never designed, inline-blocks have that infuriating space between elements, and absolute positioning just doesn't belong in a world of responsive design. But, there may be hope: enter flexbox.

In this talk, we'll look at the basics of using flexbox, as well as working through a few traditionally-tricky layout problems that can be solved more easily with this set of properties. We'll also discuss about how flexbox is used at Shopify specifically, including the quirks we've run into. Finally, we'll get into why flexbox isn't a panacea, and how it might fit into a world with other layout techniques being used side-by-side.

---

About Chris Sauvé

Chris is a relative newcomer to the world of design and development. Three years ago, he became enamoured with the joy of solving complex programming problems and left his accounting career to pursue one in front-end development. Now, he spends his days working as a front-end developer at Shopify, and his nights playing board games, ultimate, and building on open-source projects both big and small (including bigfoot, a tool for building beautiful, responsive popovers for footnotes, and an as-yet-unreleased automated pattern library generator).

Published in: Internet
  • Be the first to comment

Exploring Flexbox with Chris Sauvé

  1. 1. FLEXBOX
  2. 2. CHRIS SAUVE
  3. 3. LAYOUT STRATEGIES
  4. 4. TABLES
  5. 5. JUST DON’T.
  6. 6. ABSOLUTE POSITIONING
  7. 7. INLINE BLOCK
  8. 8. FLOATS
  9. 9. THINK DIFFERENT
  10. 10. CONTENT-OUT LAYOUT
  11. 11. parent child 1 child 2 child 3
  12. 12. 1 2 3
  13. 13. BROWSER SUPPORT
  14. 14. YES YES -­‐webkit YES10+ only -­‐ms  in  IE10 YES even  in  Mini!
  15. 15. YES YES -­‐webkit YES10+ only -­‐ms  in  IE10 YES even  in  Mini! CAN I USE SAYS… 92.12%
  16. 16. PARENT RULES
  17. 17. display:  flex;  //  or  inline-­‐flex flex-­‐direction:  row;  //  or  column
  18. 18. 1 2 3 flex-­‐direction:  row;
  19. 19. 1 2 3 flex-­‐direction:  column;
  20. 20. display:  flex;  //  or  inline-­‐flex flex-­‐direction:  row;  //  or  column
  21. 21. display:  flex;  //  or  inline-­‐flex flex-­‐direction:  row;  //  or  column align-­‐items:  stretch;
  22. 22. 1 2 3 Cross Axis align-­‐items
  23. 23. 1 2 3 align-­‐items:  stretch;  //  default
  24. 24. 1 2 3 align-­‐items:  center;
  25. 25. 1 2 3 align-­‐items:  flex-­‐start;
  26. 26. 1 2 3 align-­‐items:  flex-­‐end;
  27. 27. display:  flex;  //  or  inline-­‐flex flex-­‐direction:  row;  //  or  column align-­‐items:  stretch;
  28. 28. display:  flex;  //  or  inline-­‐flex flex-­‐direction:  row;  //  or  column align-­‐items:  stretch; justify-­‐content:  center;
  29. 29. 1 2 3 Main Axis justify-­‐content
  30. 30. 1 2 3 justify-­‐content:  center;
  31. 31. 1 2 3 justify-­‐content:  flex-­‐start;
  32. 32. 1 2 3 justify-­‐content:  flex-­‐end;
  33. 33. 1 2 3 justify-­‐content:  space-­‐between;
  34. 34. 1 2 3 justify-­‐content:  space-­‐around;
  35. 35. display:  flex;  //  or  inline-­‐flex flex-­‐direction:  row;  //  or  column align-­‐items:  stretch; justify-­‐content:  center;
  36. 36. display:  flex;  //  or  inline-­‐flex flex-­‐direction:  row;  //  or  column align-­‐items:  stretch; justify-­‐content:  center; flex-­‐wrap:  nowrap;
  37. 37. 1 2 3 flex-­‐wrap:  nowrap;
  38. 38. 1 2 3 flex-­‐wrap:  wrap;
  39. 39. CHILD RULES
  40. 40. flex-­‐grow:  0; flex-­‐shrink:  0; flex-­‐basis:  auto;
  41. 41. flex-­‐basis:  <number>; flex-­‐basis:  auto; width:  <number>; =
  42. 42. 1 2 3 100px 20px 20px 20px
  43. 43. 1 2 3 100px 20px 20px 20px 40px of “growth” available
  44. 44. 1 2 3 flex-­‐grow:  0; flex-­‐grow:  0; flex-­‐grow:  0;
  45. 45. 1 2 3 flex-­‐grow:  1; 13px of growth flex-­‐grow:  1; 13px of growth flex-­‐grow:  1; 13px of growth
  46. 46. 1 2 3 flex-­‐grow:  1; 10px of growth flex-­‐grow:  2; 20px of growth flex-­‐grow:  1; 10px of growth
  47. 47. 1 2 3 flex-­‐grow:  0; 0px of growth flex-­‐grow:  1; 20px of growth flex-­‐grow:  1; 20px of growth
  48. 48. 1 2 3 40px 20px 20px 20px
  49. 49. 1 2 3 40px 20px 20px 20px 20px of “shrink” available
  50. 50. flex-­‐shrink:  0; flex-­‐shrink:  0; flex-­‐shrink:  0; 1 2 3
  51. 51. flex-­‐shrink:  0; flex-­‐shrink:  1; flex-­‐shrink:  1; 1 0px of shrink 10px of shrink 10px of shrink
  52. 52. NO SILVER BULLET
  53. 53. FLEXBOX @SHOPIFY
  54. 54. GRID SYSTEM
  55. 55. .next-­‐grid  {      display:  flex;   } .next-­‐grid__cell  {      flex-­‐grow:  1;      flex-­‐shrink:  1;      flex-­‐basis:  0;   } .next-­‐grid__cell .next-­‐grid__cell .next-­‐grid
  56. 56. TABS
  57. 57. Scale proportionately Don’t scale Only fill space when there’s overflow
  58. 58. .next-­‐tab  {      flex-­‐grow:  1;      flex-­‐shrink:  1;      flex-­‐basis:  auto;   }.next-­‐tab__list-­‐-­‐has-­‐overflow  {      display:  flex;      align-­‐items:  stretch;   } .next-­‐tab__list-­‐-­‐has-­‐overflow .next-­‐tab .next-­‐tab .next-­‐tab .next-­‐tab .next-­‐tab-­‐-­‐disclosure .next-­‐tab-­‐-­‐disclosure  {      flex-­‐grow:  0;      flex-­‐shrink:  0;      flex-­‐basis:  auto;   }
  59. 59. POPOVERS
  60. 60. Max Height Scrollable, fill available space As small as possible, always visible
  61. 61. .next-­‐popover__pane  {      flex-­‐grow:  0;      flex-­‐shrink:  1;      flex-­‐basis:  auto;      overflow:  scroll;   } .next-­‐popover__content  {      display:  flex;      flex-­‐direction:  column;      align-­‐items:  stretch;   } .next-­‐popover__content .next-­‐popover__pane
  62. 62. .next-­‐popover__pane-­‐-­‐fixed  {      flex-­‐grow:  0;      flex-­‐shrink:  0;      flex-­‐basis:  auto;      overflow:  hidden;   } .next-­‐popover__content .next-­‐popover__pane .next-­‐popover__pane-­‐-­‐fixed
  63. 63. LIVE DEMOS
  64. 64. https://css-tricks.com/snippets/css/a-guide-to-flexbox/ CSS-TRICKS REFERENCE
  65. 65. FLEXBUGS https://github.com/philipwalton/flexbugs
  66. 66. THANKS EVERYONE!

×