Created
January 5, 2022 11:09
-
-
Save elfacht/e74e13e10a496ec2364a36290b1c29f3 to your computer and use it in GitHub Desktop.
Format list inline with more than X items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @source https://css-tricks.com/solved-with-css-logical-styling-based-on-the-number-of-given-elements/ */ | |
/* 5 or more items display next to each other */ | |
li:first-child:nth-last-child(n + 5), | |
li:first-child:nth-last-child(n + 5) ~ li { | |
display: inline; | |
} | |
/* Adds semicolon after each item except the last item */ | |
li:first-child:nth-last-child(n + 5) ~ li::before { | |
content: ';'; | |
margin: 0 0.5em 0 -0.75em; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment