javascript – shuffle HTML list element order

var ul = document.querySelector(‘ul’); for (var i = ul.children.length; i >= 0; i–) { ul.appendChild(ul.children[Math.random() * i | 0]); } This is based on Fisher–Yates shuffle, and exploits the fact that when you append a node, it’s moved from its old place. Performance is within 10% of shuffling a detached copy even on huge lists … Read more

How can I create multi columns from a single unordered list?

Yes, you can create a multi column list as described if you make the ul a flex container, change the flex-direction to column, allow it to wrap by applying flex-wrap: wrap and additionally force it to wrap by limiting its height: ul { height: 100px; display: flex; flex-direction: column; flex-wrap: wrap; } <ul> <li>item 1</li> … Read more

tech