I have a fixed-width container and I want to display a dynamic amount of same-sized items that should be aligned to the right side of the container.
When there are too many items, they should wrap into multiple lines. However, I want the bottom lines to fill completely and the top-most line with the remaining space.
I thought I could achieve this with flex layout (like justify-content: flex-end;), but I didn't succeed.
How (if possible) could I produce the desired placement with CSS rules?
HTML can be assumed to be very basic:
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<!-- ... -->
<div class="item">N</div>
</div>
Note: all items have the same dimensions, I just didn't draw them accurately in the images.

