简体   繁体   English

Fancybox 不会尊重身高

[英]Fancybox won't respect height

if I don't set the height of the box and leave it by default: the scrollbar is shown as the box is not big enough如果我不设置框的高度并默认保留:滚动条显示为框不够大

在此处输入图片说明

$('#newsletter').fancybox({
    'type': 'iframe',
    'href': 'http://es.solmelia.com/nSubscriber/jsp/C_Subscribe_Newsletter.jsp',
});

if I set it to 400:如果我将其设置为 400:

在此处输入图片说明

$('#newsletter').fancybox({
    'type' : 'iframe',
    'href' :   'http://es.solmelia.com/nSubscriber/jsp/C_Subscribe_Newsletter.jsp',
    'padding' : '20',
    'height' : '400'
});

(looks way bigger than 400) (看起来比 400 大得多)

also tried也试过

$('#newsletter').fancybox({
    'type'              : 'iframe',
    'href'          :   'http://es.solmelia.com/nSubscriber/jsp/C_Subscribe_Newsletter.jsp',
    'height' : '400px',
    'transitionIn'  :   'elastic',
},function(){$.fancybox.resize();});

which gives same result as first example这给出了与第一个例子相同的结果

You can try using the public method resize , once content has been loaded, see method description :您可以尝试使用公共方法resize ,加载内容后,请参阅方法说明:

* Auto-resizes FancyBox height to match height of content *自动调整 FancyBox 的高度以匹配内容的高度

Ref : http://fancybox.net/api参考: http : //fancybox.net/api

Method Usage : $.fancybox.resize();方法用法: $.fancybox.resize();

What you can try :你可以尝试什么:

    $('#newsletter').fancybox({
                        'type'          : 'iframe',
                        'href'          : 'http://es.solmelia.com/nSubscriber/jsp/C_Subscribe_Newsletter.jsp',
                        'scrolling'     : 'no',
                        onComplete : function(){ $.fancybox.resize();}
                });

onComplete - Will be called once the content is displayed onComplete - 显示内容后将被调用

I think the issue you have here is actually inside the iFrame not fancybox.我认为您在这里遇到的问题实际上是在 iFrame 内部而不是fancybox。 An iframe will not set its dimensions based on the size of the content within. iframe 不会根据其中的内容大小设置其尺寸。 my recommendation would be to avoid iframes as they are almost always problematic我的建议是避免使用 iframe,因为它们几乎总是有问题

  1. Sometimes, It occurs due to zoom.有时,它是由于缩放而发生的。
  2. Can you try updating the 'height' : '400px' .您可以尝试更新'height' : '400px' It may works.它可能有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM