I am using media queries and flex layout to display my items in a container.
It can be 1 column display or 2 columns or 3 columns or 4 columns or 5 columns or 6 columns depending on the screen size.
For example:
<div class="containter">
<item>item1<item>
<item>item2<item>
<item>item3<item>
<item>item4<item>
<item>item5<item>
</div>
If the display is 2 columns, I would like to target only
<item>item5<item>
And if,
<div class="containter">
<item>item1<item>
<item>item2<item>
<item>item3<item>
<item>item4<item>
<item>item5<item>
<item>item6<item>
</div>
If the display is 2 columns, I would like to target both
<item>item5<item>
<item>item6<item>
If the display is 3 columns, I would like to target 3 items
<item>item4<item>
<item>item5<item>
<item>item6<item>
Is there a CSS selector to target items in the last row?
I was hoping to find the first item in the last row and then find siblings using ~ selector, but cant seem to get one working.
Update: ** Not a duplicate of Targeting flex items on the last row since this link doesn't provide any solution. I am looking for some solution.