I have a collection of dynamically generated divs that act as panels for selecting different options. These divs can be categorized into two types: regular and short. The height of the regular divs is determined using JavaScript to match the height of the tallest one. If the height of the short div is less than half of the maximum height, it is set to half of that height; otherwise, it retains its full height.
My current goal (ideally utilizing CSS) is to arrange these items in a way that allows for placing one short div below another short div if there is adequate space available.
Below are some visual aids to help clarify the situation: