【发布时间】:2017-06-06 19:51:46
【问题描述】:
我使用的是 fancybox 2.1.5 版 我想要做的是在大约宽度 900 和高度 500 的 fancybox iframe 中显示大图像。当然,现在图像呈现巨大并且不适合该 iframe。 我很难捕捉到正确的类或导航到图像以调整其大小的方法。我尝试的是使用 beforeShow 函数并执行此操作:
$(".fancybox").fancybox({
type: 'iframe',
href: source,
title: title,
width: 900,
height: 500,
closeBtn: false,
nextSpeed: 0, //important
prevSpeed: 0, //important
beforeShow: function() {
alert('its working!');
$(".fancybox-iframe img").css("width","900px");
$(".fancybox-iframe img").css("height","auto");
$(".fancybox-iframe img").addClass("imageResize");
}
});
但是,$(".fancybox-iframe img") 和 $(".fancybox-inner img") 都不是触发 img 的正确方法。
如何使用beforeShow 函数在fancybox iframe 中正确调整图像大小。
谢谢!
【问题讨论】:
标签: jquery fancybox-2