I have a slightly hypothetical question:
If I had a <ul>, and I wanted to use css grids to display the <li> in a vertical list, is there a way to automate this, so that if the number of <li> changed, the number of rows would increase/decrease automatically?
Example:
ul {
display: grid;
grid-template-rows: repeat(NUM, 1fr);
}
<ul>
<li>item one</li>
<li>item two</li>
<li>item three</li>
</ul>
Here the NUM specifies the number of rows in the template, but if I were to add another <li> I would then have to go and change the NUM value.
Is there a way to recognise the number of child elements and set the number of rows automatically accordingly?
I am asking hypothetically in case I have missed any cdd grid specs, - I am not looking for any hacks around, and especially am not looking for a javascript workaround - it just seems a little too inflexible not to have the option to automate this, I am new to grids and am just figuring out how it works.