jQuery Fancybox iframe 大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15683079/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 15:35:14  来源:igfitidea点击:

Fancybox iframe size

jqueryiframefancybox

提问by Ryan

I've searching everywhere for this problem. When the user clicks on a link, it loads a fancybox with an iframe. For some reason, the iframe however is a tiny size. I have tried adjusting the width, height, minWidth and minHeight settings, but it makes no difference.

我到处寻找这个问题。当用户点击一个链接时,它会加载一个带有 iframe 的fancybox。出于某种原因,iframe 然而是一个很小的尺寸。我曾尝试调整宽度、高度、minWidth 和 minHeight 设置,但没有任何区别。

Here's the relevant code in the header (I have all the Fancybox scripts linked):

这是标题中的相关代码(我链接了所有 Fancybox 脚本):

 <script type="text/javascript">
$(document).ready(function() {
    $(".fancybox").fancybox();
});
</script>

<script type="text/javascript">
    $(document).ready(function() {
     $("iframe").fancybox({
        'width': 600,
        'height': 250,
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'type': 'iframe'
    });
});
</script>

And html:

和 html:

 <a class="fancybox fancybox.iframe"  href="iframe.html">link here </a>

Any ideas?

有任何想法吗?

回答by JFK

If you have this html

如果你有这个 html

<a class="fancybox fancybox.iframe"  href="iframe.html">link here </a>

then the selector you are binding to fancybox is .fancybox.

那么你绑定到fancybox的选择器是.fancybox.

fancybox.iframeon the other hand, is a special classintroduced in version 2.xthat indicates what typeof content fancybox needs to open and you don't need to do anything specific with it, so :

fancybox.iframe另一方面,是在2.x 版本中引入的一个特殊,它表示需要打开什么内容,并且你不需要对它做任何特定的事情,所以:type

<script type="text/javascript">
    $(document).ready(function() {
     $(".fancybox").fancybox({
        'width': 600,
        'height': 250,
        'transitionIn': 'elastic', // this option is for v1.3.4
        'transitionOut': 'elastic', // this option is for v1.3.4
        // if using v2.x AND set class fancybox.iframe, you may not need this
        'type': 'iframe',
        // if you want your iframe always will be 600x250 regardless the viewport size
        'fitToView' : false  // use autoScale for v1.3.4
    });
});
</script>

that should do the trick.

这应该够了吧。

Bear in mindthat if you are using fancybox v2.x, the API options are new and not compatible with previous versions. Check http://fancyapps.com/fancybox/#docsfor the complete list of options, methods and callbacks for that version.

请记住,如果您使用的是fancybox v2.x,API 选项是新的并且与以前的版本不兼容。检查http://fancyapps.com/fancybox/#docs以获取该版本的选项、方法和回调的完整列表。

回答by julian

try setting autoScale=false

尝试设置 autoScale=false

julian

朱利安