调整花式框 iframe 叠加层宽度和高度时出现问题

Problem adjusting Fancybox iframe overlay width and height

本文关键字:高度 问题 iframe 叠加 调整      更新时间:2023-09-26

我正在使用 Fancybox 创建一个带有 iframe 的叠加层,一切正常,但我似乎无法更改宽度/高度的值。我正在使用 fancybox-1.2.6 和 jquery1.2.6

$(document).ready(function() {
        $("a.iframe").fancybox({
     'width' : '75%',
     'height' : '75%',
     'autoScale' : false,
     'transitionIn' : 'none',
     'transitionOut' : 'none',
     'type' : 'iframe'
});
    });

<a class="iframe" id="iframe" title="Sample title" href="http://google.com/">iframe</a>
以下是在

固定大小的花哨框中手动打开iframe的方法

$.fancybox.open({
  'href': 'mypage.html',
  'type': 'iframe',
  'autoSize': false,
  'width': 800,
  'height': 800
}); 

你必须直接更改它的css,因为fancybox实际上不是jquery的一部分。

$("#fancybox").css({'width': '500px', 'height': '500px'}); 

有那种方式或类似的东西,

jQuery(document).ready(function() {
$.fancybox(
    {
        'autoDimensions'    : false,
        'width'             : 350,
        'height'            : 'auto',
        'transitionIn'      : 'none',
        'transitionOut'     : 'none'
    }
);
});

我通过在链接标签中添加宽度和高度属性来解决此问题,如下所示:

<a id="various3" href="action.html" width="60%" height="60%">Iframe</a>

你喜欢的盒子代码:

$("#popup").fancybox({
    'autoScale'     : false,
    'width'         : $("a#popup").attr("width"),
    'height'        : $("a#popup").attr("height"),
    'transitionIn'  : 'elastic',
    'transitionOut' : 'elastic',
    'type'          : 'iframe'
});

请不要使用Firefox。它不起作用,他们没有使高度兼容,请尝试铬!(今天最新的火狐!如果它是受支持的浏览器,请删除 PX 的引号,为 % 加上引号,例如:

'width': 400; //400 pixels;
'width': '75%'; //75% of the screen
//height do not work on Mozilla Firefox (today!)

试试这个

    $(".fancyboxiframe").fancybox({
        fitToView:false,
        autoSize:false,
        'width':parseInt($(window).width() * 0.7),
        'height':parseInt($(window).height() * 0.55),
        'autoScale':true,
        'type': 'iframe'
    });

这在过去对我有用。我必须同时设置高度和宽度。

 $(document).ready(function() {         
    $("a.iframe").fancybox({
                    'autoDimensions'    : false,
                    'width'             : 600,
                    'height'            : 150,
                    'transitionIn'      : 'elastic',
                    'transitionOut'     : 'elastic',
                    'type'              : 'iframe'
                });
    });

尝试使用:

'maxHeight' : 380,