JFK*_*JFK 19
一种更简单的方法是使用beforeShow回调更改两者的大小,fancybox打开的图像和fancybox父容器:
$(".fancybox").fancybox({
fitToView: false, // avoids scaling the image to fit in the viewport
beforeShow: function () {
// set size to (fancybox) img
$(".fancybox-image").css({
"width": 800,
"height": 600
});
// set size for parent container
this.width = 800;
this.height = 600;
}
});
Run Code Online (Sandbox Code Playgroud)
请参阅JSFIDDLE
注意:这适用于fancybox v2.x +
编辑(2014年4月):
使用当前版本的fancybox(今天的v2.1.5),没有必要将css规则应用于.fancybox-image选择器,因为图像现在设置为response (max-width: 100%;).this.width而且this.height独自一人会做到这一点
$(".fancybox").fancybox({
fitToView: false,
beforeShow: function () {
this.width = 800;
this.height = 600;
}
});
Run Code Online (Sandbox Code Playgroud)
请参阅forked JSFIDDLE
| 归档时间: |
|
| 查看次数: |
14496 次 |
| 最近记录: |