Create a CSS Grid that flows by column, with dynamic columns and rows based on content
问题 I have a dynamic number of elements (all of equal dimensions). I want to position them in a grid, such that they are ordered in columns, with a dynamic number of columns based on the available container width, and with a dynamic number of rows based on the number of elements. For example, assuming there are 9 elements: 1 4 7 2 5 8 3 6 9 But if the container width expands: 1 3 5 7 9 2 4 6 8 Or shrinks: 1 6 2 7 3 8 4 9 5 This works fine when the items are positioned by row, but not by column.