I have a grid - 4 columns per row. I am using CSS grid layout.
Say there could potentially be an infinite number of elements.
<div class="grid">
<div class="item"></div>
<div class="item"></div>
</div>
How can I select the two middle elements of each row if the number of elements is potentially infinite. For example, for the first three lines, I would need to select:
nth-child(2)
, nth-child(3)
, nth-child(6)
, nth-child(7)
, nth-child(10)
,nth-child(11)
I could hard code the styles to a certain number, assuming there would be no infinite number, but if there is a way to do it dynamically, I would rather do it.

source
share