【发布时间】:2017-09-27 12:08:40
【问题描述】:
我在 colorbox 中打开一个 youtube 视频,因为我需要根据视口大小以特定大小打开它,所以我创建了一个函数来计算 colorbox 覆盖大小并在打开时传递它:
overlaysize = overlaySize();
$.colorbox({
href: url,
iframe:true,
opacity: 0.8,
transition: 'none',
innerWidth: overlaysize['neww'],
innerHeight: overlaysize['newh']
});
在调整大小时,我需要更新尺寸:
$( window ).resize(function() {
if ( $('#colorbox').length ) {
overlaysize = overlaySize();
$.colorbox.resize({
innerWidth: overlaysize['neww'],
innerHeight: overlaysize['newh']
});
}
});
但它不起作用。盒子没有调整大小 在同一页面内。我正在使用一个使用颜色框的脚本。 我不确定它是否打印了一些覆盖我的颜色框脚本的代码。
我可以以某种方式引用我的颜色框实例吗?
【问题讨论】:
-
如果颜色框内的内容在窗口调整大小时自行调整大小,那么只需调用
$.colorbox.resize() -
如果我删除了其他使用 colorbox 的脚本,我的工作正常
标签: javascript jquery colorbox