2012-09-21 74 views
0

我正在使用fancybox插件到我的網站之一。我真的很喜歡使用它,直到遇到此問題。在fancybox裏面我想把手風琴給它。問題是我希望fancybox的高度增長,當手風琴崩潰時不顯示滾動條。自動高度fancybox2

請點擊here我當前的代碼

回答

2

您需要打開盒子看中後更新的高度。更新你的代碼添加afterShow

$(".fancybox").fancybox({ 
    openEffect : 'elastic', 
    openSpeed : 150, 
    closeEffect : 'elastic', 
    closeSpeed : 150, 
    autoDimensions: true, 
    height: 'auto', 
    afterShow: function(){ 
     $.fancybox.update() 
    } 
}); 

這裏是工作演示,http://jsfiddle.net/muthkum/wufGk/1/

+0

與第一個答案相同的想法,但更好的實現。感謝muthu。 – lidongghon

0

我已經高度後添加以下代碼:「自動」在下面的網址 http://jsfiddle.net/sunnyjaysabuero90/wufGk/,它的工作原理

 

    $(".fancybox").fancybox({ 
     openEffect : 'elastic', 
     openSpeed : 150, 
     closeEffect : 'elastic', 
     closeSpeed : 150, 
     autoDimensions: true, 
     height: 'auto', 

    beforeShow: function(){ 
     this.width = $('.fancybox-iframe').contents().find('html').width(); 
     this.height = $('.fancybox-iframe').contents().find('html').height(); 
     } 
     fitToView: false 
    }); 

    $('.accordionButton').click(function() { 
     $('.accordionButton').removeClass('accordionButton-open'); 
     $('.accordionContent').slideUp('fast'); 
     if($(this).next().is(':hidden') == true) { 
     $(this).addClass('accordionButton-open'); 
     $(this).next().slideDown('fast'); 
     } 
    });