如何在fancybox V2中为iframe设置不同的高度/宽度? [英] How do you set different height/width for iframe in fancybox V2?
问题描述
我一直在使用Fancybox 1.3.4,在那儿,我具有链接本身中iframe的尺寸.
I have been using Fancybox 1.3.4, and right there I have the dimensions of the iframe in the link itself.
这是我如何拥有它的一个例子
Here is an example of how I have it
test.html?width=675&height=470
当我单击链接时,fancybox将打开具有这些尺寸的iframe.我正在尝试Fancybox V2,但对于如何设置iframe的尺寸感到困惑.我希望每个iframe都有不同的尺寸.我该怎么办?
When I click on the link fancybox will open the iframe with those dimensions. I am trying Fancybox V2, but I'm confused on how to set the dimensions for the iframes. I want every iframe to have different dimensions. How would I do it?
推荐答案
像这样设置您的html(使用HTML5 DOCTYPE
):
Set your html (with HTML5 DOCTYPE
) like this:
<a class="fancybox fancybox.iframe" data-width="675" data-height="470" href="test.html" >test</a>
<a class="fancybox fancybox.iframe" data-width="400" data-height="200" href="test2.html" >test 2</a>
(在每个元素的data-
属性上设置width
和height
)
(set width
and height
on the data-
attributes for each element)
然后使用此脚本:
$("a.fancybox").fancybox({
fitToView: false,
afterLoad: function(){
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
}
}); // fancybox
应该在fancybox v2.x中达到目的
should do the trick in fancybox v2.x
这篇关于如何在fancybox V2中为iframe设置不同的高度/宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!