我正在使用 Fancybox 2 作为图片库。我想弄清楚如何通过源图像制作自动缩略图。在示例中,有 2 张图像,其中一张是原始图像,另一张是缩略图。我只想设置原始图像,Fancybox 应该自动创建缩略图。
<p>
<a class="fancybox" rel="gallery1" href="http://farm2.staticflickr.com/1617/24108587812_6c9825d0da_b.jpg"> </a>
<a class="fancybox" style="margin-left: 20px" rel="gallery1" href="http://farm4.staticflickr.com/3691/10185053775_701272da37_b.jpg"></a>
<a class="fancybox" style="margin-left: 20px" rel="gallery1" href="http://farm1.staticflickr.com/574/22407305427_69cc6e845f_b.jpg"></a>
<a class="fancybox" style="margin-left: 20px" rel="gallery1" href="http://farm1.staticflickr.com/291/18653638823_a86b58523c_b.jpg"></a>
</p>
js
$("a.fancybox").fancybox({
openEffect: 'none',
closeEffect: 'none'
});
如您所见,我没有指定缩略图 img。有什么办法可以自动创建吗?我的缩略图有多种。它可以在 1-10 之间。
最佳答案
类似这样的吗?
jQuery('.fancybox').each(function(i,e){
jQuery(e).css('background-image','url('+jQuery(e).attr('href')+')');
});
关于javascript - Fancybox 2 自动缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37865197/