Skip to content

Instantly share code, notes, and snippets.

@alexdiliberto
Created August 26, 2017 05:10
Show Gist options
  • Save alexdiliberto/ba4a4369c03392934146b5d53ed8973c to your computer and use it in GitHub Desktop.
Save alexdiliberto/ba4a4369c03392934146b5d53ed8973c to your computer and use it in GitHub Desktop.
matches the last item only if the list has exactly N items
/*
matches the last item only if the list has exactly N items
e.g. for N = 3:
*/
$N: 3;
:nth-last-child(-n+#{$N}):first-child ~ li:nth-child(#{$N}) {
color: red;
}
/* compiles to :nth-last-child(-n+3):first-child ~ li:nth-child(3) */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment