调整Fancybox iframe覆盖宽度和高度的问题

我正在使用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' }); }); 

 iframe 

以下是在固定大小的fancybox中手动打开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' } ); }); 

我通过向link标签添加width和height属性来解决这个问题,如下所示:

 Iframe 

你的fancybox代码:

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

请不要使用Firefox。 它不起作用,它们没有使高度兼容,而是尝试镀铬! (今天最新的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,