I was struggling with the following issue in CSS. I have an arbitrary number of elements (spaces or divs) that I want to wrap inside a container in the form of a snake.
I mean, if I have 10 elements, each of which is 20 pixels wide, I would like them to appear as follows in a container of 60 pixels wide:
0 1 2 5 4 3 6 7 8 9
I tried using flexbox in CSS, but I can only get the elements that will be displayed as follows:
0 1 2 3 4 5 6 7 8 9
If this can help, I know the exact width of the individual elements, but I don't know the width of the container.
Any help would be greatly appreciated.
Thank you in advance!
source share