Finally I found a way to make borders around my floated divs collapse like on table cells. The key was to use box-shadow instead of border. So this is actually a trick to simulate borders.
I couldn't use
display:table-cell
because table cells don't get rearranged vertically the way I want in responsive scenarios.
You can try to resize the browser window to further explore how the "borders" behave.
The first container:
The second container: