在css中为移动设备和桌面设备优化lightbox2

问题描述 投票:0回答:1

我正在为大学的论文实施一个网站,它包括一个画廊。我下载了lightbox2 js文件并使其正常工作。

我的网站也将针对移动屏幕进行优化,并且想知道我将如何使用lightbox2。

lightbox2
1个回答
0
投票

尝试在文件lightbox.js中替换306行(对于v2.10.0):

maxImageWidth  = windowWidth - self.containerPadding.left - self.containerPadding.right - self.imageBorderWidth.left - self.imageBorderWidth.right - 20;

maxImageHeight = windowHeight - self.containerPadding.top - self.containerPadding.bottom - self.imageBorderWidth.top - self.imageBorderWidth.bottom - 120;

以下内容:

if (($(window).width() > 300) && ($(window).width() < 993)) {

maxImageWidth  = windowWidth - self.containerPadding.left - self.containerPadding.right - self.imageBorderWidth.left - self.imageBorderWidth.right - your values; 

maxImageHeight = windowHeight - self.containerPadding.top - self.containerPadding.bottom - self.imageBorderWidth.top - self.imageBorderWidth.bottom - your values;

} else {

maxImageWidth  = windowWidth - self.containerPadding.left - self.containerPadding.right - self.imageBorderWidth.left - self.imageBorderWidth.right - 20;

maxImageHeight = windowHeight - self.containerPadding.top - self.containerPadding.bottom - self.imageBorderWidth.top - self.imageBorderWidth.bottom - 120;

}

或者您可以单独设置宽度和高度:

if (($(window).width() > 300) && ($(window).width() < 500)) {

maxImageWidth  = windowWidth - self.containerPadding.left - self.containerPadding.right - self.imageBorderWidth.left - self.imageBorderWidth.right - your values;

maxImageHeight = windowHeight - self.containerPadding.top - self.containerPadding.bottom - self.imageBorderWidth.top - self.imageBorderWidth.bottom - your values;

} 

else if (($(window).width() >= 500) && ($(window).width() < 993)) {

maxImageWidth  = windowWidth - self.containerPadding.left - self.containerPadding.right - self.imageBorderWidth.left - self.imageBorderWidth.right - your values;

maxImageHeight = windowHeight - self.containerPadding.top - self.containerPadding.bottom - self.imageBorderWidth.top - self.imageBorderWidth.bottom - your values;

} else {

maxImageWidth  = windowWidth - self.containerPadding.left - self.containerPadding.right - self.imageBorderWidth.left - self.imageBorderWidth.right - 20;

maxImageHeight = windowHeight - self.containerPadding.top - self.containerPadding.bottom - self.imageBorderWidth.top - self.imageBorderWidth.bottom - 120;

}

不要忘记设置你的价值观。

© www.soinside.com 2019 - 2024. All rights reserved.