如何动态创建图像的拼贴(网格没有间隙),其中图像有不同的高度? [英] How do I dynamically create a collage (grid with no gaps) of images, where images have different heights?

查看:370
本文介绍了如何动态创建图像的拼贴(网格没有间隙),其中图像有不同的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示一个缩略图页面。缩略图是用户上传的图片图片。每张图片都有约束宽度,但不是约束高度,这是为了显示完整图片而不进行任何裁剪。

I want to display a page of thumbnails. The thumbnails are user uploaded artwork images. Each image has a constrained width, but not a constrained height, this is to show the full image without any cropping.

我想让图片互相对接没有间隙。列数不固定:如果我展开或调整页面大小,图像应该流入正确的列数。

I want the images to butt up against each other with no gaps in between. The number of columns is not fixed: If I expand or resize the page the images should flow into correct number of columns.

float:left


b $ b

是ALMOST,我想要什么。除非页面中有高大的图片,否则我会得到这个缺口:

is ALMOST, what I want. Except when there are tall images in the page I get this gapped look:

如何消除差距?

推荐答案

如果你想在css中做到这一点,你必须为每一列创建div,并浮动这些列(但它弄乱了图像的顺序)。

If you want to do this in css only you have to create divs for every column, and float those columns (but it messes up order of images).

或者,您可以使用jquery插件,如这一个

Alternatively, you can use jquery plugin like this one.

这篇关于如何动态创建图像的拼贴(网格没有间隙),其中图像有不同的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆