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

CSS: The Boring Bits

CSS: The Boring Bits

Peter Gasston

March 12, 2012
Tweet

More Decks by Peter Gasston

Other Decks in Programming

Transcript

  1. Boring things* The Matrix Revolutions The Lord of the Rings

    films Coldplay Apple vs Android *Removed images of dubious provenance
  2. An interesting paradox: The more boring a CSS feature is,

    the more excited I get when someone does something cool with it.
  3. background-position: h n v n; background-position: right 20px bottom 10%;

    Four values allows more flexible placing of background images.
  4. border-clip: [x y]; border-clip: [visible invisible]; border-clip: 10px 1fr 10px;

    Custom border shapes; clip the border to show the areas you want.
  5. body { font-size: 10px; } h1 { font-size: 2.4em; }

    h1 span { font-size: 0.9167em; } h1 span { font-size: 2.2rem; } rem The rem unit is always relative to the root font-size, not that of its parent as em is.
  6. vh, vw, vmin 100vw div { width: 25vw; } vh

    = viewport height, vw = viewport width, vmin = either vh or vw, whichever is smaller. It’s a length measure that’s relative to the viewport, not the parent.
  7. attr(title) attr(data-color color) attr() The attr() value will now accept

    more than strings, as it currently does. You can specify the type to be color, url, number, and more.
  8. div::before { content: 'foo'; } div { content: replaced 'foo';

    } It’s proposed that you be able to replace content in any element, rather than just ::after or ::before.
  9. cycle() em { font-style: cycle(italic,normal); } Will cycle through the

    values depending on inherited values. For example, em will be have font-style: italic if its parent is normal, or normal if its parent is italic.
  10. :target e { color: #F00; } e:target { color: #00F;

    } :target is applied to an internal link which the user has followed; e.g. <a href=”#foo”>
  11. :matches() .foo .bar h1, .foo .bar h2, .foo .bar h3

    {} .foo .bar :matches(h1,h2,h3) {}
  12. :any-link :local-link :link, :visited :any-link means any link, regardless of

    its visited state; :local-link is for links on the same domain.
  13. :future :past :current Selectors based on temporal position, such as

    combined with audio, video, screen readers.
  14. label:hover /for/ input E /x/ F A bit complicated this;

    the x value is an attribute of E which is equal to the id value of F. Best example is <label for=”foo”> <input id=”foo”>
  15. $E > F The parent selector!!! The element E has

    styles applied if it contains element F.
  16. :root { data-foo: #F00;} h1 { color: data(foo);} http://dev.w3.org/csswg/css-variables/ CSS

    Variables. Uses the data- pattern from the HTML5 data attributes. Scoped by applying to elements.