Javascript Fancybox 宽度不适用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4980930/
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
Fancybox width not applying
提问by Webnet
回答by Felix Kling
You probably have to set autoSize
to false
:
您可能必须设置autoSize
为false
:
$('a#city-prompt').fancybox({
'width': 750,
'autoSize': false
});
About width
from the documentation:
关于width
从文档:
Width for content types 'iframe' and 'swf'. Also set for inline content if 'autoDimensions' is set to 'false'
内容类型“iframe”和“swf”的宽度。如果 'autoDimensions' 设置为 'false',也为内嵌内容设置
回答by d-_-b
None of the answers here worked for me, but this did the trick:
这里没有一个答案对我有用,但这确实有效:
$.fancybox({
'content':$("#element").html(),
'width':'500',
'autoDimensions':false,
'type':'iframe',
'autoSize':false
});
The 'autoSize':false
was the missing key
那'autoSize':false
是丢失的钥匙
回答by Shuhad zaman
Try this.
You need to set autoSize
to false
:
尝试这个。您需要设置autoSize
为false
:
$(".fancybox").fancybox({'width':400,
'height':300,
'autoSize' : false});
回答by jobima
In Fancybox version 2 and above use 'autoSize':false
在 Fancybox 版本 2 及更高版本中使用 'autoSize':false
回答by Matteo Cuellar
Make sure to not include the ' when writing out width in pixels. So instead of
确保在以像素为单位写出宽度时不包括 '。所以代替
'width' : '100', you should have 'width' : 100,
'width' : '100', 你应该有 'width' : 100,
Hope that helps...
希望有帮助...
回答by Nick
In addition to the other answers, to fix the height issue I changed line 998
除了其他答案之外,为了解决高度问题,我更改了第998行
from :to.height = currentOpts.height + double_padding;
从 :to.height = currentOpts.height + double_padding;
to:to.height = parseInt(currentOpts.height) + parseInt(double_padding);
到:to.height = parseInt(currentOpts.height) + parseInt(double_padding);
回答by yangtao
Change _get_zoom_to
(on line 690) from
更改_get_zoom_to
(在第 690 行)从
to.width = currentOpts.width + double_padding;
to
到
to.width = parseInt(currentOpts.width) + parseInt(double_padding);