Skip to content

Instantly share code, notes, and snippets.

@mishelen
Created April 9, 2015 15:36
Show Gist options
  • Select an option

  • Save mishelen/6ae10cba8917ce8093e9 to your computer and use it in GitHub Desktop.

Select an option

Save mishelen/6ae10cba8917ce8093e9 to your computer and use it in GitHub Desktop.
Quantity Queries
// Quantity 6
li:nth-last-child(6):first-child,
li:nth-last-child(6):first-child ~ li {
/* rules */
}
// The advantage of :nth-last-of-type(),
// on the other hand, is that you are able
// to target groups of like elements
// where other siblings of different types are present.
// More than or equal to 6
li:nth-last-child(n+6),
li:nth-last-child(n+6) ~ li {
/* rules */
}
// apply the described technique across different element type siblings
.container > :nth-last-child(n+3),
.container > :nth-last-child(n+3) ~ * {
/* rules */
}
// Fewer than or equal to 6
li:nth-last-child(-n+6):first-child,
li:nth-last-child(-n+6):first-child ~ li {
/* rules */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment