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>
你在上面的代码看不出什么问题?感谢您的回答!