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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 15:04:12  来源:igfitidea点击:

Fancybox width not applying

javascriptfancybox

提问by Webnet

Using the following JS the width isn't being adjusted. It doesn't get adjusted when I use '750'or '750px'

使用以下 JS 不会调整宽度。当我使用'750''750px'

$('a#city-prompt').fancybox({
    'width': 750
});

I've posted on the fancyboxforums about this and haven't gotten a response

我已经在fancybox论坛上发布了关于这个的帖子,但没有得到回应

回答by Felix Kling

You probably have to set autoSizeto false:

您可能必须设置autoSizefalse

$('a#city-prompt').fancybox({
    'width': 750,
    'autoSize': false
});

About widthfrom 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':falsewas the missing key

'autoSize':false是丢失的钥匙

回答by Shuhad zaman

Try this. You need to set autoSizeto false:

尝试这个。您需要设置autoSizefalse

$(".fancybox").fancybox({'width':400,
                         'height':300,
                         'autoSize' : false});

回答by jobima

In Fancybox version 2 and above use 'autoSize':false

在 Fancybox 版本 2 及更高版本中使用 'autoSize':false

Fancybox Documentation

Fancybox 文档

回答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);