Suppose I have a layout of some arbitrary number of small divs, and one big div. I want to have one row of the small divs, as many as can fit in the container width, followed by the big div, which takes up the full width. It will also flex in height, maintaining its aspect ratio (contains an image). Any remaining small divs then continue after the big one. As the container expands and contracts, small divs would move below/above the big one as space allows. Hoping for CSS-only solution (open to JS though).
So initially:
---------------------
| d1 | d2 | d3 | d4 |
---------------------
| DB |
---------------------
| d5 | d6 | d7 | d8 |
---------------------
Then the container shrinks, causing this layout:
----------------
| d1 | d2 | d3 |
----------------
| DB |
----------------
| d4 | d5 | d6 |
----------------
| d7 | d8 |
I'm envisioning a flexbox solution but haven't been able to make it work.