gpt4 book ai didi

jquery - Slimbox2 适合窗口 - CSS, jQuery

转载 作者:行者123 更新时间:2023-11-28 18:10:02 25 4
gpt4 key购买 nike

我正在为我的画廊使用 Slimbox2,但缺少一项重要功能 - 调整框架大小以适合屏幕。当图像太大时,它会超出屏幕。有没有人找到解决方案?

Plugin official site

Api documentation

解决这个问题对我来说真的很重要,在此先感谢!

最佳答案

我遇到了同样的问题,我是这样做的:

我打开了 slimbox2.js 文件并替换了:

$(image).css({backgroundImage: "url(" + activeURL + ")", visibility: "hidden", display: ""});
$(sizer).width(preload.width);
$([sizer, prevLink, nextLink]).height(preload.height);

与:

     /* make sure the image won't be bigger than the window */
window.innerWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; //ie fix
window.innerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; //ie fix
var winWidth = window.innerWidth-200; //browser width
var winHeight = window.innerHeight-100; //browser height
var my_w = preload.width; //original width
var my_h = preload.height; //original height

// scale width
var scaleW1 = winWidth;
var scaleH1 = (my_h * winWidth) / my_w;

// scale height
var scaleW2 = (my_w * winHeight) / my_h;
var scaleH2 = winHeight;
var scale = (scaleW2 > winWidth);

if (scale) {
reswidth = Math.floor(scaleW1);
resheight = Math.floor(scaleH1);

}
else {
reswidth = Math.floor(scaleW2);
resheight = Math.floor(scaleH2);

}
if ($("p").hasClass("slimboxie")){
$(image).css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader( src='"+ activeURL + "', sizingMethod='scale')", visibility: "hidden", display: ""});

$(sizer).width(reswidth);
$([sizer, prevLink, nextLink]).height(resheight); }
else {

$(image).css({backgroundImage: "url(" + activeURL + ")", backgroundSize: reswidth + "px " + resheight + "px", visibility: "hidden", display: ""});
$(sizer).width(reswidth);
$([sizer, prevLink, nextLink]).height(resheight);

}

我是业余爱好者,所以请善待 :) 如果您对修复它有任何疑问,请问我 :)

关于jquery - Slimbox2 适合窗口 - CSS, jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18862545/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com