6

I'm able to resize the height with the $.fancybox.resize(); part, but the width just doesn't update according to the new content. Thoughts?

johnnyArt
  • 4,327
  • 5
  • 29
  • 28

5 Answers5

8

From the fancybox api docs:

$.fancybox.resize: "Auto-resizes FancyBox height to match height of content."

So it looks like it is not intended to adjust the width.

If you wish to adjust the width, you can do it by manually resizing the #fancybox-wrap and #fancybox-inner elements. After some very quick checking, it looks like #fancybox-wrap is set to 20px wider than #fancybox-inner:

$('#fancybox-inner').width(400);
$('#fancybox-wrap').width(420);

You can also control the width when you first register fancybox using the width option:

$('#somelink').fancybox({ width: '100px' });
Brett Ryan
  • 26,937
  • 30
  • 128
  • 163
TM.
  • 108,298
  • 33
  • 122
  • 127
4

In newer versions of fancybox (1.3.4 in my case) use

$('#fancybox-content').width(600);

instead of

$('#fancybox-inner').width(400);

for manually adjusting the width

Hannes
  • 41
  • 1
1

make some changes in jquery.fancybox.js near about line nubmer:837 change

current.width = loadingBay.width();

to

current.width = loadingBay.width() + 2*current.padding;

it worked fine to me.

bhattraideb
  • 407
  • 7
  • 25
1

Here's what worked for me:

$('#fancybox-wrap, #fancybox-outer, #fancybox-content').css('width', 'auto');
$.fancybox.center();
earachefl
  • 1,880
  • 7
  • 31
  • 55
-1

Just open jquery.fancybox.js and add your own width. Here is my code with width = 72%.

// Reset dimensions so we could re-check actual size
        wrap.add(skin).add(inner).width('72%').height('auto').removeClass('fancybox-tmp');
Badar
  • 1,430
  • 1
  • 15
  • 19