Problem adjusting Fancybox iframe overlay width and height

我与影子孤独终老i 提交于 2019-12-08 06:45:53

问题


I'm using Fancybox to create an overlay with an iframe everything works but I can't seem to change the values of the width/height. I'm using fancybox-1.2.6 and jquery1.2.6

$(document).ready(function() {

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

and

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

回答1:


Here's how to manually open an iframe in a fixed sized fancybox

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



回答2:


you have to directly change the css of it since fancybox isnt actually part of jquery.

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

there is that way or something like this,

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



回答3:


I solved this problem by adding a width and a height attribute to the link tag like this:

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

And you fancybox code:

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



回答4:


Please do not use Firefox. It doesn't work, they did not make height compatible, try chrome instead! (latest Firefox today!) if it is a supportable browser, remove the quotes for px, put quotes for %, like:

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



回答5:


just try this

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



回答6:


This has worked for me in the past. I had to set both the height and the width.

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

                });
    });



回答7:


try to use:

'maxHeight' : 380,


来源:https://stackoverflow.com/questions/6048216/problem-adjusting-fancybox-iframe-overlay-width-and-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!