How do I dynamically create a collage (grid with no gaps) of images, where images have different heights?(如何动态创建图像的拼贴(没有间隙的网格),其中图像具有不同的高度?)
问题描述
我想显示一页缩略图.缩略图是用户上传的艺术品图像.每张图片都有一个限制的宽度,但没有限制的高度,这是为了显示完整的图像而不进行任何裁剪.
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
几乎是我想要的.除非页面中有高大的图像,否则我会看到这种间隙:
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).
或者,您可以使用 this one 之类的 jquery 插件.
Alternatively, you can use jquery plugin like this one.
这篇关于如何动态创建图像的拼贴(没有间隙的网格),其中图像具有不同的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何动态创建图像的拼贴(没有间隙的网格),其中图像具有不同的高度?


基础教程推荐
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01