将列表拆分为 X 列
问题是将项目列表拆分为可变数量的列,以最大化网页上的显示(注意,它们是从左到右显示的)
如果列表中有 15 个项目,它们会进入一列 如果列表中有 20 个项目,则它们分为两列 如果列表中有 30 个项目,则它们分为两列 最多可以有 8 列来消除水平。 再次滚动
,目标是最大化显示,这解释了上面的轻微不一致 为了确定列数,我可以使用代码的变体 if ( cnt > 100, col = 8 ) else if ( cnt > 60 col = 5 ).... 等等 但我希望有一个更好的公式来确定列数?
输出的形式是
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35
36 37 38 39 40 41 42
43 44 45 46 47 48 49
50 51 ........
希望问题清楚,如有任何问题请告诉我
The problem is to split a list of items into a variable number of columns to maximize the display on the web page ( note, they are displayed from left to right )
If there are 15 items in the list, they go in one column
if there are 20 items on the list, they go in two columns
if there are 30 items on the list, they go in two columns
there can be max 8 columns to eliminate horiz. scrolling
again, the goal is to maximize the display which accounts for the slight inconsistency above
to determine the # of columns, i could use a variation of the code
if ( cnt > 100, col = 8 ) else if ( cnt > 60 col = 5 ).... etc.
but i hope there's a better formula for determing the column count ?
the output would be of the form
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35
36 37 38 39 40 41 42
43 44 45 46 47 48 49
50 51 ........
hope the problem is clear, any questions let me know
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这看起来像吗?
does this seem like it ??