2012-01-06 52 views
1

我使用Colorbox來顯示iframe內容。一些iframe比原來的大(打開時設置了寬度和高度),所以我使用這個解決方案 - How can I dynamically resize the jQuery Colorbox plugin? - 在加載後調整Colorbox的高度。破碎的Colorbox調整動畫

問題是,當Colorbox變小時,它會從下往上拉伸內容高度,而不是很好地將其拉伸到頁面中心。我希望它看起來完全如您在帶有圖片的colorbox示例中看到的那樣:http://jacklmoore.com/colorbox/example1/第一個鏈接。

開幕顏色框父:

 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1 /jquery.min.js"></script> 
    <script type="text/javascript" src="scripts/jquery.colorbox-min.js"></script> 
    <script type="text/javascript"> 
    $(document).ready(function(){ 
    $.extend($.colorbox.settings, {fastIframe:true, speed:350, transition:'elastic', scrolling:false, opacity:0.6, close:'Zavřít', overlayClose:false}); 
    $(".iframe").colorbox({iframe:true, width:'640px', height:'480px'}); 
    }); 
    </script> 

中的iframe調整大小:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> 
    <script type="text/javascript" src="scripts/jquery.colorbox-min.js"></script> 
    <script type="text/javascript"> 
    $(document).ready(function(){ 
     parent.$.colorbox.settings.overlayClose = true; 
     var y = $('#cbox').height() + $('#cbox').offset().top + 30; 
     parent.$.colorbox.resize({width:'644px', innerHeight:y}); 
    }); 
    </script> 

你在上面的代碼看不出什麼問題?感謝您的回答!

回答

2

所以我找到了解決方案!

問題是,我試圖編輯默認colorbox.css。 而我不小心刪除了:#cboxContent{background: #fff;}沒有這條線導致錯誤。