Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jonathansousa/2598343 to your computer and use it in GitHub Desktop.
Save jonathansousa/2598343 to your computer and use it in GitHub Desktop.
CSS: Hide n in List but not Last
&.last {
display:none;
}
&:nth-child(n+6) { /* Set the number to the number of menu items to show including "more" */
display:none;
&:nth-last-child(-n+1) {
display:block;
}
}
&.last:nth-child(6) { /* Make sure this number matches the menu items above to hide the more item at the right time */
display:none;
}
&.last {
display:none;
}
&:nth-child(n+6) { /* Set the number to the number of menu items to show including "more" */
display:none;
&:nth-last-child(-n+1) {
display:block;
}
}
&.last:nth-child(6) { /* Make sure this number matches the menu items above to hide the more item at the right time */
display:none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment