CSS alone cannot achieve this.
Trying to select the first item in each line of a multiline flex container when the number of items is unknown is too complex for CSS capabilities. This is because the first item on each line can vary and may not follow a specific pattern.
In situations where there is no clear pattern, CSS will not be sufficient and you will require a different technology.
You might want to consider using JavaScript instead.
The limitations present in CSS Grid Layout are similar:
- How to target a specific column or row in CSS Grid Layout?