Skip to content

Instantly share code, notes, and snippets.

@jonathantneal
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathantneal/cf221e5ff33492e50180 to your computer and use it in GitHub Desktop.
Save jonathantneal/cf221e5ff33492e50180 to your computer and use it in GitHub Desktop.
Welcome to IE9

Now that the bar has been set to Internet Explorer 9, I’m excited to bring some CSS to your attention.

Select things by their hierarchy: :first-child, :last-child, :only-child, :nth-child, :nth-last-child

Or by type: :first-of-type, :last-of-type, :only-of-type, :nth-of-type, :nth-last-of-type

Or not:

.transaction:not(.cancelled)

Style missing things:

.cell:empty {
  display: none;
}

Style IDs when they match the #hash. Accessible nav wins:

<a href="#navigation" class="hamburger">
#navigation { display: none; }
#navigation:target { display: block; }

Working with forms? :enabled, :disabled, :checked, :indeterminate

Gain massive control of the copy displays: ::first-line, ::first-letter

And speaking of :: double colons, write truer versions of some old favorites: ::before, ::after

And speaking of forgotten IE8 features, remember how useful this can be:

section {
  counter-reset: some_arbitrary_name;
}

section .heading:before {
  content: counter(some_arbitrary_name);
  counter-increment: some_arbitrary_name;
}

Now, welcome to the oughts, because we finally have these properties:

x {
  opacity: 0.875;
  quotes: '“'' ''' '‘' '’';
}

And we can finally use these values:

.light--important {
  background: hsla(170, 50%, 45%, 0.8);
  color: rgba(0,0,0,0.75);
}

And speaking of color, reference the current color:

.hr {
  background-color: currentColor;
}

Join the tenties, because we have media querties:

@media (min-device-width: 20em) {}

And we can move elements:

.rad {
  transform: rotate, scale, skew, translate, matrix, perspective, and 3D stuff;
}

And we can reference the root font size:

.row {
  font-size: 0;
}

.col {
  font-size: 1rem;
}

It gets better.

We can go absolutely crazy with element metrics using calc:

.callout {
  border-width: calc(1em / 3);
  width: calc(100% - 1rem);
}

And do the same with backgrounds:

.ad {
  background-clip: border-box; /* works like box-sizing for coverage or positioning */
  background-origin: content-box; /* see above  */
  background-size: cover / contain / 100% 50%;
}

And speaking of backgrounds, we can use data URIs (without 32KB limit):

.bg--monkey {
  background-image: url(data:[<mime>][;charset=<charset>][;base64],<encoded data>);
}

While we’re here, we can leverage SVGs (and use them as data URIs!).

Also, we can drop everything but WOFF (and use them as data URIs, too!)

Oh, and speaking of fonts, you can use more than four weights and styles to a single font family.

@jameskerr
Copy link

Thanks, Jonathan. This is awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment