I have done already 2 questions related with the issue I'm having. But here I have created a better example. Please see below. The boxes are being loaded by Angular ng-bind.
Please see the following code pen: http://codepen.io/anon/pen/LRPwZP
As well, I'm including the same snippet into stackoverflow, but be aware that it's not possible to resize the resolution, therefore, the example might not be useful.
It's very important to notice the desired behaviour:
- Every box has the same width (of 700px in the real case)
- Box #1 is desired to be at the top left.
- Box #2 is desired to be at the right of the box #1 only if there's enough space.
- Box #3 if still screen has space, goes at the right of box #2.
- Now, assuming there's no longer space at the right, of box #3
- Box #4, falls at the bottom of box #1.
- Box #5, goes directly at the bottom of the box #2.
- Box #6, goes directly at the bottom of the box #3.
- so on...
- Boxes are loaded using angular ng-bind, and are dynamic.
I can't use the following options:
(1)
:nth-child(odd) { float: left; }
:nth-child(even) { float: right; }
Reason: useless and fails when you need more than 2 columns.
(2) I'm aware of AngularJS Masonry, I don't want to increase the loading time, and I want to accomplish this using only CSS.
For references:
- No CSS frameworks are being use.
- Pure "Vainilla" JS is being use - occasionally.
- AngularJS is heavy used.
Previous questions, same issue:
CSS multiple different height float left elements arranged in 2 columns
Flex, AngularJS + Masonry, akoenig/angular-deckgrid and more
Kind regards, Chris,