I do not think that you can achieve what you are trying to do without reorganizing the markup. Most likely you will have to put your divs in column containers (at least until flexbox is widely used!).
Quick example:
HTML:
<div class="container"> <div class="col-1"> <img border="0" src="download.jpg" alt="Pulpit rock"> <img border="0" src="1.jpg" alt="Pulpit rock"> </div> <div class="col-2"> <img border="0" src="1.jpg" alt="Pulpit rock"> </div> </div>
CSS:
img { display: block; } .container > div { float: left; }
Explaination:
The natural flow, if elements are embedded, should appear next to each other until a line break is required. If the items are block level, they will always be displayed below the previous item. Another option is to move the elements, but it will appear again next to the first element, if there is a place, not at the bottom.
That's why you have to set up your layout to group the elements you want in a vertical line, and then place the next group next to it.
source share