How can I make fancyBox 2 adjust its height to fit its contents?

Chris picture Chris · Apr 29, 2013 · Viewed 15.1k times · Source

I'm trying to get my fancyBox to expand in height when its contents are taller than the viewport. That way, the user scrolls its contents using the browser's scroll bar. Instead, my fancyBox keeps getting its own scroll bar.

I'm just using inline content, not an iframe. These are the options I set:

$('.fancybox').fancybox({
    autoSize: 'false',
    fitToView: 'false',
    maxWidth: 940
});

Adding scrolling: 'no' cuts off the content at the bottom. Explicitly defining a really tall height works, but I want the height to be determined dynamically.

Answer

JFK picture JFK · Apr 29, 2013

Boolean and integer values should go without quotes so this

$('.fancybox').fancybox({
    autoSize: 'false',
    fitToView: 'false',
    maxWidth: 940
});

should be

$('.fancybox').fancybox({
    autoSize: false, // shouldn't be true ?
    fitToView: false,
    maxWidth: 940
});

fitToView is actually the option that gives you what you need but the quoted "false" didn't make it work for you. On the other hand, I am not sure you should disable autoSize because otherwise the inline content won't get its own height.