简体   繁体   English

Fancybox宽度不适用

[英]Fancybox width not applying

Using the following JS the width isn't being adjusted. 使用以下JS,宽度未被调整。 It doesn't get adjusted when I use '750' or '750px' 使用'750''750px'时无法调整

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

I've posted on the fancybox forums about this and haven't gotten a response 我已经在fancybox论坛上发布了这个并没有得到回应

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'. 内容类型“iframe”和“swf”的宽度。 Also set for inline content if 'autoDimensions' is set to 'false' 如果'autoDimensions'设置为'false',也会为内联内容设置

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是丢失的密钥

Try this. 试试这个。 You need to set autoSize to false : 您需要将autoSize设置为false

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

In Fancybox version 2 and above use 'autoSize':false 在Fancybox版本2及更高版本中使用'autoSize':false

Fancybox Documentation Fancybox文档

Make sure to not include the ' when writing out width in pixels. 确保在写出宽度(以像素为单位)时不包括'。 So instead of 而不是

'width' : '100', you should have 'width' : 100, 'width':'100',你应该'宽度':100,

Hope that helps... 希望有帮助......

In addition to the other answers, to fix the height issue I changed line 998 除了其他答案,为了解决高度问题我改变了第998

from : 来自:
to.height = currentOpts.height + double_padding;

to: 至:
to.height = parseInt(currentOpts.height) + parseInt(double_padding);

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

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

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