Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Flexbox: One Giant Leap for Web Layout

Stephen Hay
October 22, 2013

Flexbox: One Giant Leap for Web Layout

My talk on Flexbox for Breaking Development 2013 in Nashville

Stephen Hay

October 22, 2013
Tweet

More Decks by Stephen Hay

Other Decks in Design

Transcript

  1. Designers aren’t stupid. Many designers are willing to explore web

    tech as a design tool, but we have to make the right things easier. Flexbox is a step in the right direction.
  2. Terminology Flex containers Flex items Main axis / size /

    dimension Cross axis / size / dimension Start / end
  3. Hi, Bob. #bob { display: flex; } (Bob is a

    flex container) display: flex | inline-flex
  4. Flex items Items in a flex container are, by default,

    flex items (even anonymous block boxes) I’m a flex item! Me too! Me three!
  5. Direction #bob { flex-flow: row wrap; } #bob { flex-direction:

    row | row-reverse | column | column-reverse; flex-wrap: no-wrap | wrap | wrap-reverse; } SHORTHAND:
  6. Start & End depends on direction CROSS START CROSS END

    MAIN END CENTER MAIN START in the case of flex-direction: row
  7. Start & End depends on direction MAIN START MAIN END

    CROSS END CENTER CROSS START in the case of flex-direction: column
  8. Flex .foo { flex: 0 1 150px; } .flex-item {

    flex: flex-grow flex-shrink flex-basis; } EXAMPLE:
  9. Flex .foo { flex: 0 1 150px; } .flex-item {

    flex: flex-grow flex-shrink flex-basis; } EXAMPLE:
  10. Flex .foo { flex: initial; } .foo { flex: 0

    1 auto;} IS EQUIVALENT TO: common values (1) width: 150px width: 150px width: 150px
  11. Flex .foo { flex: auto; } .foo { flex: 1

    1 auto;} IS EQUIVALENT TO: common values (2) width: 150px width: 150px width: 150px
  12. Flex .foo { flex: none; } .foo { flex: 0

    0 auto;} IS EQUIVALENT TO: common values (3) width: 150px width: 150px width: 150px
  13. Flex .foo { flex: [n]; } .foo { flex: [n]

    1 0%;} IS EQUIVALENT TO: common values (4) flex: 1 flex: 1 flex: 1
  14. Alignment along the main axis: justify-content (align-content for multiple lines

    along cross axis) JUSTIFY-CONTENT #bob { justify-content: flex-start | flex-end | center | space-between | space-around } in the case of flex-direction: row
  15. Alignment along the cross axis: align-items (align-self can be applied

    to the flex items themselves/individually) ALIGN-ITEMS #bob { align-items: flex-start | flex-end | center | baseline | stretch } in the case of flex-direction: row
  16. Order changes the visual order vs. the source order 3

    1 2 .item:nth-child(3) { order: -1; } .foo { order: [n]; }
  17. Common use cases True centering (both axes) Multi-box layouts (products,

    teasers) Unknown menu items Display order Wrapping (menu items, boxes) Tab groups Form layout
  18. The hardest thing to learn about new tools is not

    how to use them, but when to use them.