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

The ABCs of CSS You've Likely Never Used

The ABCs of CSS You've Likely Never Used

That Conference 2017

Alicia Sedlock

August 08, 2017
Tweet

More Decks by Alicia Sedlock

Other Decks in Technology

Transcript

  1. The ABCs of CSS Properties You’ve Likely Never Used (Well,

    Mostly!) Alicia Sedlock | @aliciability
  2. Hi!

  3. A additive-symbols “… specify symbols when the value of a

    counter system descriptor is additive.”
  4. dialog { /* some dialog styles */ } dialog::backdrop {


    
 background: black;
 opacity: .5;
 
 }
  5. D :default
 
 “…represents any user interface element that is

    the default among a group of similar elements.”
  6. :default { background-color: pink; } <form> <input type=“button” value=“Button” />

    <input type=“submit” /> <input type=“reset” /> </form>
  7. div {
 
 background: lightblue;
 
 } div:empty {
 


    background: pink;
 
 } <div><!— No content —></div> <div>Hello world!</div> <div>
 <!— No content —>
 </div>
  8. F ::first-letter
 
 “…applies styles to the first letter of

    the first line of a block-level element…”
  9. p::first-letter {
 
 color: red;
 font-size: 3em;
 font-weight: bold;
 


    }
 
 <p>
 <img src=“fox.jpg” />
 The quick brown fox
 </p>
  10. I :in-range
 
 “…matches when the value currently contained inside

    an <input> element is inside the range limits specified by the min and max attributes.”
  11. <label>Enter a number 1-10</label>
 <input type="number" min="1" max="10" value="12" />


    
 input:in-range {
 background-color: rgba(0, 255, 0, 0.25);
 }
 
 input:out-of-range {
 background-color: rgba(255, 0, 0, 0.25);
 border: 2px solid red;
 }
  12. J justify-content
 ONLY ENTRY
 
 “…defines how the browser distributes

    space between and around content items along the main axis of their container.”
  13. .container {
 display: flex;
 justify-content: <value>;
 } <div class=“container”>
 <div><!—

    Content! —></div>
 <div><!— Content! —></div>
 <div><!— Content! —></div>
 </div>
  14. .container {
 display: flex;
 justify-content: flex-start;
 } <div class=“container”>
 <div><!—

    Content! —></div>
 <div><!— Content! —></div>
 <div><!— Content! —></div>
 </div>
  15. .container {
 display: flex;
 justify-content: flex-end;
 } <div class=“container”>
 <div><!—

    Content! —></div>
 <div><!— Content! —></div>
 <div><!— Content! —></div>
 </div>
  16. .container {
 display: flex;
 justify-content: center;
 } <div class=“container”>
 <div><!—

    Content! —></div>
 <div><!— Content! —></div>
 <div><!— Content! —></div>
 </div>
  17. .container {
 display: flex;
 justify-content: space-around;
 } <div class=“container”>
 <div><!—

    Content! —></div>
 <div><!— Content! —></div>
 <div><!— Content! —></div>
 </div>
  18. .container {
 display: flex;
 justify-content: space-between;
 } <div class=“container”>
 <div><!—

    Content! —></div>
 <div><!— Content! —></div>
 <div><!— Content! —></div>
 </div>
  19. 
 :lang(en) { border: 1px solid red; } :lang(fr) {

    border: 1px solid blue; } :lang(de) { border: 1px solid black; }
  20. M max-zoom
 
 “…sets the maximum zoom factor of a

    document defined by the @viewport at- rule."
  21. N negative
 
 “…alters the representation of negative counter values,

    by providing a way to specify symbols to be appended or prepended to the counter representation when the value is negative.”
  22. @counter-style negative-counter { system: numeric;
 symbols: "0" "1" "2" "3"

    "4" "5" "6" "7" "8" "9";
 negative: "(-" ")"; } .list { list-style: negative-counter; }
  23. O object-fit
 
 “…how a replaced element, such as an

    <img> or <video>, should be resized to fit its container.”
  24. /* Base styles for examples */
 img { width: 400px;

    height: 500px; border: 5px solid pink; object-fit: <value>; }
  25. <div> Lorem ipsum dolor sit amet… </div> <div class="overlay"> I

    am an overlay. Try selecting the text behind me. </div>
  26. .overlay { position: absolute; top: 0; left: 40%; background: rgba(0,0,0,.75);

    height: 200px; width: 250px; color: white; padding: 1em; pointer-events: auto; }
  27. <span>According to Groot, <q>I am Groot.</q>.</span> 
 q { quotes:

    "**" “**”; } q:before { content: open-quote; } q:after { content: close-quote; }
  28. <span>Peter Quill says <q>I'm pretty sure the answer is <q>I

    am Groot</q>.</q></span> 
 q { quotes: ’””’ ‘“”’ “‘’” “‘’”; } q:before { content: open-quote; } q:after { content: close-quote; }
  29. R revert
 
 “…rolls back the cascade so that a

    property takes on the value it would have had if there were no styles in the current style origin"
  30. @counter-style counter-options { system: fixed;
 symbols: A B C D

    E F G;
 suffix: “) ”; } .list { list-style: counter-options; }
  31. pre { tab-size: 4; /* integer values */
 tab-size: 2;


    tab-size: 10px; /* length values */
 tab-size: 2em; }
  32. <pre class=“default"> &#9;This is a line in pre! &#9;CSS is

    a lot of fun. :) </pre> pre { border: 1px solid black;
 width: 500px; }
  33. <pre class=“default"> &#9;This is a line in pre! &#9;CSS is

    a lot of fun. :) </pre> pre { border: 1px solid black;
 width: 500px;
 tab-size: 4; }
  34. <pre class=“default"> &#9;This is a line in pre! &#9;CSS is

    a lot of fun. :) </pre> pre { border: 1px solid black;
 width: 500px;
 tab-size: 100px; }
  35. U unset
 
 “…resets a property to its inherited value

    if it inherits from its parent, and to its initial value if not.”
  36. <p>I want to be blue text!</p> <div class="foo"> <p>I want

    to be orange text :(</p> </div> <div class="bar"> <p>I don't want to be orange.</p> </div> .foo { color: orange; } .bar { color: green; } p { color: blue; } .bar p { color: unset; }
  37. V vw/vh “Equal to 1% of the width/height of the

    viewport's initial containing block.”
  38. W will-change “…provides a way for authors to hint browsers

    about the kind of changes to be expected on an element, so that the browser can set up appropriate optimizations ahead of time…”
  39. A warning on will-change • Intended as a “last resort”

    - don’t prematurely optimize • Meant to be used sparingly
  40. Some of these things are • Experimental technology • In

    working draft • In initial definition