对齐/排序 HTML 中不同尺寸的图像
因此,我有这个简洁的缩略图 PHP 类,可以在漂亮的网格中对图像进行排序,但我发现网格并不总是显示图像的最佳方式。
我遇到的问题是各种标识应该显示在任意大小的容器框中。每个标识具有不同的大小(即,下采样的缩略图大小是标识的按比例调整大小的版本)。
因此,假设我们希望将标识限制为 120x120 像素的虚拟方框,这意味着生成的缩略图可能包含 120x20 和 30x120 等的图像。它们的尺寸各不相同,但每个标识的“长”边都不超过 120 像素。
好的,现在进行排序。你们对我如何打印这些有好的建议吗?我真的不想在 120x120 的方形网格空间中打印每个内容(事实上,我可以看到虚拟框可能是 200x100,因此倾向于为水平标识提供更多空间。
但是,我将如何创建一个算法(在 PHP 中)以一种看起来整齐堆叠并最适合的方式显示它们?我是否应该按垂直尺寸对它们进行排序,并且在“列表”中越远,标识就越宽
?非常感谢您的建议,如果我不清楚某些事情,请随时要求我澄清。
So, I have this neat thumbnail PHP class that sorts images in a nice grid, but I've found that a grid isn't always the best way to display images.
The problem I'm having is with an asortment of logotypes that should be displayed in an arbitrary sized container box. Each logotype is of a different size (i.e. the downsampled thumbnail-sized is a proportionally resized version of the logotype).
So, let's assume we want to limit the logotypes to a virtual square box of, say, 120x120 pixels, meaning that the resulting thumbnails may consist of images that are 120x20 and 30x120 and so on. They would all be of different sizes, yet none larger than 120 pixels on the "long" side of each logotype.
Fine, now for the sorting. Do you guys have a good suggestion as to how I would print out these? I wouldn't really want to print each in a 120x120 square grid space (in fact, I can see how the virtual box might be 200x100, and thus leaning to giving more space to horizontal logotypes.
But, how would I create an algorithm (in PHP) to display these in a way where they look neatly stacked and makes the best fit? Should I just order them by vertical size and the further you get in the "list", the wider the logotypes get?
Any suggestions is greatly appreciated, and if I'm not clear about something, feel free to ask me to clarify.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我首先按高度对它们进行分组和排序,将它们分成相似高度(+-5% 差异)的组,然后按宽度进行分组和排序。每个身高组都有自己的线。
看起来可能是这样的:
根据图像的类型或看起来更好的图像,最宽的图像排在最前面或最后。
I'd group and sort them first by height, packing them in groups of similar height (+-5% difference) and then by width. Each height group gets its own line.
Could look that way:
Depending on the type of images, or what looks better, the widest ones come first or last in the line.