【发布时间】:2014-05-07 18:37:00
【问题描述】:
我一直在使用Freewall jQuery plugin 来生成一个基于网格的响应式图片库。这样的作品,我不得不说。但是,鉴于画廊的图像是以自动方式检索的,我一直在努力寻找一种使图片可链接的方法:
<script type="text/javascript">
var temp = "<div class='cell' style='width:{width}px; height: {height}px; background-image: url(grid-images/photo/{index}.jpg)'></div>";
var w = 280, h = 320, html = '', limitItem = 15;
for (var i = 0; i < limitItem; ++i) {
html += temp.replace(/\{height\}/g, h).replace(/\{width\}/g, w).replace("{index}", i + 1);
}
$("#freewall").html(html);
var wall = new freewall("#freewall");
wall.reset({
selector: '.cell',
animate: true,
cellW: 280,
cellH: 320,
onResize: function() {
wall.refresh();
}
});
wall.fitWidth();
// for scroll bar appear;
$(window).trigger("resize");
</script>
在其他版本的代码中,Minh 已将画廊的每张图片的代码放在 html 文件中。我觉得特别有用的是 JS 代码的自动检索,我想知道...是否有一种自动方式将每张图片与某个链接相关联,从而使图片可链接?
那就是:1 到 A,2 到 B,3 到 C 等等。
【问题讨论】:
标签: javascript jquery html layout grid