Hello, I'm working on function, that takes a select
from html and replaces it with multi-column ul
- it's one list, but has float:left;
on li
children, so the number of columns is based on calculations (if ul
width is 600 and li
width is 200, i will obviously have 3 columns).
That's theory - the easy part.
Example: 5 items, 2 columns
Now, When I take data from select, I have this list:
1
2
3
4
5
If I just push the array into ul
, it will look like this on screen:
1 2
3 4
5
But for user/reader, it's easier and better, when you don't read Left->Bottom
, but rather Bottom->Left
, meaning that you're reading until bottom of column and then move to next column, rather than reading row, then next row.
So I need to transform list to columns:
1 4
2 5
3
so, in reality in ul
will be this order:
1 4 2 5 3
And this needs to work with variable column number, because if we decide to add 10 items to list, it might look better with more columns.
Any help with needed operators/cycles and math involved?
Thank you