The only thing you have to do is to add the special data-fancybox-href
attribute to your img
tag like:(您唯一要做的就是将特殊的data-fancybox-href
属性添加到img
标签中,例如:)
<img data-fancybox-href="http://farm4.staticflickr.com/3864/14420515212_9999c800b4_b.jpg" src="http://farm4.staticflickr.com/3864/14420515212_9999c800b4_b.jpg" style="float:right; padding:5px; width:200px;" class="zoom" />
Notice that both attributes, src
and data-fancybox-href
are pointing to the same image, but data-fancybox-href
is used to open it in fancybox without the constrains of the img
tag.(注意,两个属性src
和data-fancybox-href
都指向同一图像,但是data-fancybox-href
用于在fancybox中打开它,而不受img
标签的约束。)
Forked PEN(分叉笔)
PS.(PS。) you could optionally add closeClick: true
to your fancybox initialization so fancybox closes when clicking the opened image(您可以选择将closeClick: true
添加到fancybox初始化中,以便在单击打开的图像时fancybox关闭)
$(".zoom").fancybox({
closeClick: true
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…