Last active
August 8, 2018 08:14
-
-
Save geoffreycrofte/508332453c6a3538ae36 to your computer and use it in GitHub Desktop.
A way to apply styles depending on number of elements
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
li:only-of-type { | |
width: 100%; | |
} | |
/* if 2 <ul> childs */ | |
li:nth-last-child(2):first-child, | |
li:nth-last-child(2):first-child ~ li { | |
width: 50%; | |
} | |
/* if 3 <ul> childs */ | |
li:nth-last-child(3):first-child, | |
li:nth-last-child(3):first-child ~ li { | |
width: 33.333%; | |
} | |
/* etc. */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment