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

The CSS of Tomorrow

Peter Gasston
September 07, 2012

The CSS of Tomorrow

Canvas conference, 7 September 2012. #canvasconf

Peter Gasston

September 07, 2012
Tweet

More Decks by Peter Gasston

Other Decks in Technology

Transcript

  1. Predicting the Future “There’s no chance that the iPhone is

    going to get any significant market share. No chance.” - Steve Ballmer, 2007
  2. I Predict: Cynicism “That sounds cool but it's useless because

    we'll have to wait for browsers to catch up.”
  3. Root-relative units html { font-size: 10px; } p { font-size:

    1.4em; }←14px p span { font-size: 0.8572em; }←12px 0.85714285714286
  4. Root-relative units html { font-size: 10px; } p { font-size:

    1.4rem; }←14px p span { font-size: 1.2rem; }←12px Much better. http://www.w3.org/TR/css3-values/
  5. Root-relative units E { width: 65%; } F { width:

    76.9231%; }←55% of root 76.923076923077%
  6. Root-relative units E { width: 65vw; } F { width:

    55vw; }←55% of root Pukka. http://www.w3.org/TR/css3-values/
  7. Selectors li { color: #00F; } ol li { color:

    #F00; } ol.foo li { color: #00F; } ol:not(.foo) li { color: #F00; } http://www.w3.org/TR/css3-selectors/
  8. Selectors ol span, ul span, p span {} *:matches(ol,ul,p) span

    {} http://www.w3.org/TR/2011/WD-selectors4-20110929/
  9. Selectors http://example.com/foo/bar/ <a href="http://example.com/foo/bar/" /> a:local-link {} <a href="http://example.com/" />

    a:local-link(0) {} <a href="http://example.com/foo/" /> a:local-link(1) http://www.w3.org/TR/2011/WD-selectors4-20110929/
  10. Selectors E /foo/ F <label for="foo" /> <input id="foo" />

    label /for/ input {} label:hover /for/ input {} http://www.w3.org/TR/2011/WD-selectors4-20110929/
  11. Selectors E! > F !E > F !E! > F

    E!!1! > F The Parent Selector! http://dev.w3.org/csswg/selectors4/
  12. Media Queries @media (script: 0) {} @media (hover) {} @media

    (pointer: fine|coarse) {} http://dev.w3.org/csswg/mediaqueries4/
  13. Media Queries @media screen and (min-width: 400px) {} @media screen

    and (min-width: 960px) {} @media screen and (resolution: 2dppx) {}
  14. Media Queries @media screen { @media (min-width: 400px) {} @media

    (min-width: 960px) {} @media (resolution: 2dppx) {} } http://my.opera.com/ODIN/blog/2012/08/28/colourful-opera-12-50-snapshot
  15. Device Adaptation @viewport { initial-scale: 1; width: device-width; } @media

    (min-width: 800px) { @viewport { maximum-scale: 1; } }
  16. Conditionals @document url('http://foo.com/bar/') {} @document url-prefix('http://foo.com/') {} @document domain('foo.com') {}

    @document regexp('http://foo.com//[a-zA-Z]| \d{3,}/') {} Regular expressions in CSS. Finally! http://www.w3.org/TR/css3-conditional/
  17. .holder { display: flex; } .child { width: 30%; }

    .child { flex: 1; } A B .a { flex: 2; } .b { flex: 1; } Flexbox http://www.w3.org/TR/css3-flexbox/
  18. Flexbox .child { align-items: center; flex: 0; justify-content: center; }

    C A B .outer { flex-direction: column; } .a,.b { order: 2; } .c { order: 1; }
  19. Grid Layout E { display: grid; grid-definition-columns: 1fr 1fr 2fr;

    } E { grid-definition-columns: 1fr 1fr 2fr; grid-definition-rows: 10em auto 40px; } http://dev.w3.org/csswg/css3-grid-layout/
  20. Grid Layout F { grid-column-position: 2; grid-row-position: 2; } A

    B .a { grid-column: 2 2; } .b { grid-row-span: 3; }
  21. Grid Templates E { grid-template: 'head head head' 'nav main

    main' 'foot foot foot'; } .a { grid-area: 'head'; } .b { grid-area: 'main'; } A B
  22. Regions A .a { flow-into: foo; } B C D

    .b, .c, .d { flow-from: foo; } B .b { flow-from: foo; } http://dev.w3.org/csswg/css3-regions/
  23. Exclusions & Shapes E { position: absolute; } wrap-flow: both;

    http://dev.w3.org/csswg/css3-exclusions/
  24. Exclusions & Shapes E { shape-outside: circle(50%,50%, 400px); } E

    { shape-inside: circle(50%,50%, 400px); }
  25. Cascading Variables :root { var-brand-color: #F00; } h1 { border-color:

    var(brand-color); color: var(brand-color); } http://dev.w3.org/csswg/css-variables/
  26. Cascading Variables Y!$? $title = 'h1 span'; $brandcolor = '#f00';

    .foo $title { border-color: $brandcolor; color: $brandcolor; }
  27. Hierarchies .foo { border-color: red; } .foo h1 { color:

    yellow; } .foo h1 em { font-style: normal; } .foo ul { margin: 0; }
  28. Hierarchies .foo { border-color: red; & h1 { color: yellow;

    & em { font-style: normal; } } & ul { margin: 0; } } http://dev.w3.org/csswg/css3-hierarchies/
  29. “When can we use them?” 1. Browser update cycles are

    getting faster 2. The market share of IE is shrinking