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

Designing Layouts: The New Superpowers of CSS at An Event Apart San Francisco

Jen Simmons
November 02, 2016

Designing Layouts: The New Superpowers of CSS at An Event Apart San Francisco

Jen Simmons

November 02, 2016
Tweet

More Decks by Jen Simmons

Other Decks in Design

Transcript

  1. 9:00 – now Intro now – 10:00 Writing Modes 10:00

    – 10:10 Break 10:10 – 11:00 Intro to CSS Grid 11:00 – 11:10 Break 11:10 - 12:00 More CSS Grid 12:00 – 1:00 Lunch 1:00 – 2:00 Using A Grid 2:00 - 2:10 Break 2:10 – 3:00 More 3:00 – 3:10 Break 3:10 - 4:00 Layout and the Medium of the Web
  2. LATIN-BASED SYSTEMS ARABIC-BASED SYSTEMS block direction inline direction block direction

    inline direction .css {direction: rtl;} <html dir="rtl"> .css {direction: ltr;} <html dir="lrt">
  3. LATIN-BASED SYSTEMS ARABIC-BASED SYSTEMS block direction inline direction block direction

    inline direction .css {direction: rtl;} <html dir="rtl"> .css {direction: ltr;} <html dir="lrt">
  4. THREE OPTIONS FOR WRITING-MODE direction block inline direction writing-mode: vertical-lr;

    block direction inline direction writing-mode: vertical-rl; block direction inline direction toggle w/ direction writing-mode: horizontal-tb;
  5. THREE OPTIONS FOR WRITING-MODE direction block inline direction writing-mode: vertical-lr;

    block direction inline direction writing-mode: vertical-rl; block direction inline direction toggle w/ direction writing-mode: horizontal-tb;
  6. OPTIONS FOR VERTICAL WRITING-MODES direction block inline direction writing-mode: vertical-lr;

    block direction inline direction writing-mode: vertical-rl; creates a vertical typographic mode
  7. TWO MORE OPTIONS FOR WRITING-MODE block direction inline direction writing-mode:

    sideways-lr; block direction inline direction writing-mode: sideways-rl; creates a horizontal typographic mode only
  8. HAN-BASED SYSTEMS b l o c k d i r

    e c t i o i n l i n e d i r e c t i o n
  9. block direction inline direction writing-mode: sideways-rl; block direction inline direction

    writing-mode: vertical-rl; text-orientation: mixed; creates a horizontal typographic mode creates a vertical typographic mode
  10. LATIN-BASED SYSTEMS ARABIC-BASED SYSTEMS block direction inline direction block direction

    inline direction .css {direction: rtl;} <html dir="rtl"> .css {direction: ltr;} <html dir="lrt">
  11. THREE OPTIONS FOR WRITING-MODE direction block inline direction writing-mode: vertical-lr;

    block direction inline direction writing-mode: vertical-rl; block direction inline direction toggle w/ direction writing-mode: horizontal-tb; creates a vertical typographic mode
  12. TWO MORE OPTIONS FOR WRITING-MODE block direction inline direction writing-mode:

    sideways-lr; block direction inline direction writing-mode: sideways-rl; creates a horizontal typographic mode only
  13. section { direction: ltr; writing-mode: horizontal-tb; } (These are all

    the defaults. No need to specify them.) Example: Writing Mode 1A
  14. h1 { display: grid; } h1 span:nth-child(1) { grid-column: 1

    / 3; grid-row: 1 / 2; } h1 span:nth-child(2) { grid-column: 1 / 2; grid-row: 2 / 3; } h1 span:nth-child(3) { grid-column: 2 / 3; grid-row: 2 / 3; } Example: Writing Mode 3A
  15. Behind a flag Just Works On Its Way Chrome Chrome

    Canary Opera Opera Developer Firefox Firefox 
 Dev Edition Safari Technical Preview Firefox 
 Nightly Edge Safari Old Spec IE10+ -ms-* Stuck in 2012
  16. IE & Edge implementation, by Microsoft IE old spec in

    IE10+ -ms-* prefix Edge new spec TBA
  17. IE & Edge implementation, by Microsoft IE old spec in

    IE10+ -ms-* prefix Edge new spec TBA
  18. // layout using old-technology @supports (display:grid) { // overrides to

    undo old layout // layout using new-technology }
  19. IE & Edge implementation, by Microsoft IE old spec in

    IE10+ -ms-* prefix Edge new spec TBA
  20. “ — Johnny Appleseed The first browser hasn’t shipped it

    yet. It’ll take 3–5 years for other browsers to catch up. So… 2020.
  21. “ — Johnny Appleseed Grid is too buggy to use.

    Wait a year or two for it 
 to get fixed.
  22. “ — Johnny Appleseed Grid is taking too long. 


    It took 3 years to get into beta. Will be another 3 before it’s in production.
  23. “ —Rachel Andrew You should try it out now and

    complain about what you don’t like. Once it ships, it’s too late to change anything.
  24. “ — Jen Simmons Grid takes time and commitment to

    learn. Start now and get ready to use it in 6 months.
  25. <main> <div>item</div> <div>item</div> <div>item</div> this is an anonymous grid item

    <div>item</div> hello world <section>more stuff</section> <footer>conclusion</footer> </main> <ul> <li> <li> <li> <li> <li> <li> <li> <li> </ul> <body> <header> <main> <article> <h1> <p> <figure> <aside> <footer> </body>
  26. <body> <header>…</header> <main> <article> <h1> <p> <p> <p> <figure> <p>

    </article> </main> <aside>…</aside> <footer>…</footer> </body> body { display: grid; }
  27. <body> <header>…</header> <main> <article> <h1> <p> <p> <p> <figure> <p>

    </article> </main> <aside>…</aside> <footer>…</footer> </body> body { display: grid; } main { display: grid; }
  28. <body> <header>…</header> <main> <article> <h1> <p> <p> <p> <figure> <p>

    </article> </main> <aside>…</aside> <footer>…</footer> </body> body { display: grid; } main { display: grid; } article { display: grid; }
  29. <body> <header>…</header> <main> <article> <h1> <p> <p> <p> <figure> <p>

    </article> </main> <aside>…</aside> <footer>…</footer> </body> body { display: grid; } article { display: grid; }
  30. <body> <header>…</header> <main> <article> <h1> <p> <p> <p> <figure> <p>

    </article> </main> <aside>…</aside> <footer>…</footer> </body> body { display: grid; } main { display: subgrid; } article { display: subgrid; }
  31. Grid Area Grid Line Grid Track Grid Track Grid Cell

    Grid Line Grid Line Grid Line Grid Line
  32. Grid Area Grid Track Grid Track Grid Cell Grid Line

    Grid Line Grid Line Grid Line Grid Line Grid Gap Grid Gap Grid Gap
  33. • Exists in CSS • Can NOT be styled •

    It doesn’t exist 
 in the DOM
  34. 1 2 3 4 5 6 Grid Line Numbers Line

    Numbers, not track numbers — different than what we are used to! 1 2 3 4 5
  35. main { display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(4, 1fr);

    } aside { grid-column: 1 / 3; grid-row: 1 / -1; background: yellow; }
  36. .grid-container { display: grid; grid-template-columns: 1fr 1fr 1fr; } some

    other syntax options (each with different results) grid-template-columns: 1fr 5fr 2.5fr; grid-template-columns: 8em 1fr 300px; grid-template-columns: 1fr 1fr 2fr 3fr 5fr 8fr 13fr 21fr 34fr; grid-template-columns: repeat(7, 1fr); grid-template-columns: repeat(3, 200px 1fr 25%); grid-template-columns: repeat(auto-fit, 10em); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  37. Units for setting Grid Track Sizes ‣ length: px, em,

    rem, vw, vh ‣ percent ‣ factor unit: 1fr ‣ auto ‣ measurement of content: min-content / max-content ‣ minmax();
  38. .grid-item { grid-column: 1 / 5; // goes from vertical

    line 1 to 5 grid-row: 3 / 5 // goes from horizontal line 3 to 5 } some other syntax options (each with different results) grid-column: 3 / 5; // starts at line 3, goes to line 5 grid-column: 3 / span 2; // starts at line 3, spans 2 cells grid-column: span 2 / 5; // spans 2 cells, ends at line 5 grid-column: span 2; // spans 2 cells, placed by algorithm grid-column: 4; // starts at line 4 grid-column: 1 / -1; // starts at line 1, goes to line -1 grid-column: horse / pig;
  39. 1 2 3 4 5 6 grid-column: 1 / 2;

    grid-row: 1 / 2; grid-column: 5 / 6; grid-row: 1 / 2; grid-column: 2 / 4; grid-row: 2 / 3; grid-column: 3 / 5; grid-row: 3 / 5; 1 2 3 4 5 grid-column: 1 / 2; grid-row: 4 / 5;
  40. .item { grid-column-start: 2; grid-column-end: 4; grid-row-start: 1; grid-row-end: 3;}

    .item { grid-column: 2 / 4; grid-row: 1 / 3; } .item { grid-area: 1 / 2 / 3 / 4; } 1 2 3 4 grid-column: 2 / 4; grid-row: 1 / 3; 1 2 3 4 5
  41. Grid Line Numbers 1 2 3 4 5 6 -5

    -4 -3 -2 -1 -6 -5 -4 -3 -2 -1 1 2 3 4 5
  42. Place each item into a specific cell/area Let the browser

    place everything using autoplacement algorithm
  43. 11 8 9 10 7 6 5 1 2 3

    4 auto placement algorithm
  44. 13 11 8 9 10 7 6 5 1 2

    3 4 12 grid-auto-flow: dense;
  45. .container { grid-template-rows:[cow] 1fr [horse] 1fr [dog] 1fr [pig] 1fr

    [duck]; } .item { grid-column: horse / pig; } 1 2 3 4 1 2 3 4 5 cow horse dog pig duck
  46. grid-template-rows:1fr 1fr 1fr; grid-template-rows:[cow] 1fr [horse] 1fr [dog] 1fr [pig];

    grid-template-rows: repeat(auto-fit, 200px 1fr); grid-template-rows: repeat(auto-fit, [dog] 200px [cat] 1fr); grid-template-rows: repeat(4, 
 [even-start even-end] 80px [odd-start odd-end] 80px);
  47. Grid Area Grid Line Grid Track Grid Track Grid Cell

    Grid Line Grid Line Grid Line Grid Line header
  48. header { grid-area: header; } main { grid-area: main; }

    aside { grid-area: aside; } footer { grid-area: footer; } body { display: grid; grid-template-columns: 3fr 1fr; grid-gap: 2rem; grid-template-areas: "header header" "main aside" "footer footer”; } ‘header’ 4fr + 2rem ‘aside’ 1fr ‘main’ 3fr ‘footer’ 4fr + 2rem
  49. body { display: grid; grid-template-columns: 3fr 1fr; grid-gap: 2rem; grid-template-areas:

    "header" "main" "aside" "footer"; } @media (min-width: 800px) { body { grid-template-areas: "header header" "main aside" "footer footer"; } }
  50. img { width: 100%; } article { column-width: 200px; column-gap:

    2em; column-rule: 
 1px solid #444; }
  51. USING A GRID TO 
 LINE THINGS UP LIKE A

    MODERNIST WITH JEN SIMMONS
  52. what does it mean to have a 
 reading experience

    with a frame, where things move in and out of that frame?
  53. what does it mean to have a 
 interaction experience

    with a frame, where things move in and out of that frame?
  54. We must make sure our audience knows the answer 


    to this question: 
 “Where do I go to get more 
 of this thing?”
  55. “ — The Vignelli Canon Great designs can be achieved

    without the use of the grid, but the grid is a very useful tool to guarantee results. Ultimately the most important tool is the management of the white space in layouts. It is the white space that makes the layout sing. Bad layouts have no space left for breathing — every little space is covered by a cacophony of type sizes, images, and screaming titles.