Is it possible to adjust layouts in css/html based on the number of child elements?
Below is an example layout for reference.
I have tried using nth-child, but I might not be implementing it correctly...
https://codepen.io/brycesnyder/pen/EvBzWq
My goal is to make all elements occupy 50% width and stack if there are multiple ones.
/* three items */
li:first-child:nth-last-child(3):not(:first-child),
li:first-child:nth-last-child(3) ~ li {
background: green;
}
https://i.sstatic.net/wn9Qv.png
UPDATE: While it can be done with standard elements like this https://codepen.io/brycesnyder/pen/GvbbyY, I am looking to achieve the same result with just a UL > LI structure