我做了一个带有评论的灯箱。灯箱图像容器根据图像调整宽度。图像小于 400 像素,则灯箱宽度为 720,如果图像大于 720 像素,则灯箱宽度为 960。但现在的问题是。我用过
Jquery 代码根据图像的宽度调整灯箱图像容器的大小,但假设第一个图像为 400 像素,则灯箱大小为 720 像素
如果第二张图片大于 720 像素,则灯箱大小为 960 像素
通过单击下一个/上一个按钮从第一个图像移动到下一个/上一个图像时,灯箱根据前一个图像而不是当前图像尺寸宽度获取宽度。
我的jquery代码是
var tpWidth = 720;
var tpWidthnew = 960;
if ( $('.tp-mainimage').width() > tpWidth ) $('#tp-lightboxactitem').width(tpWidthnew);
图像大小(1024px)大于720px,然后灯箱大小为960px

下一张图片(180px 宽度)小于 720px 则灯箱尺寸为960px,因为之前的图像灯箱尺寸为 960px

i made a lightbox with comments . the lightbox image container adjusts with width according to the image . the image less then 400 px then the lightbox width is 720 and if image greater then 720px then lightbox width is 960. but now the problem is that . i used
Jquery code to resize the lightbox image container accoring to the width of the image but suppose 1st image of 400 px then the lightbox size is 720px
and if 2nd image is of greater then 720px then lightbox size is 960px
while moving from 1st image to next/previous image by clicking next /previous button the lightbox takes the width according to the previous image not the current image size width.
my jquery code is
var tpWidth = 720;
var tpWidthnew = 960;
if ( $('.tp-mainimage').width() > tpWidth ) $('#tp-lightboxactitem').width(tpWidthnew);
image size (1024px) greater then 720px then lightbox size is 960px

next image (180px width) less then 720px then also lightbox size is 960px due to previous image lightbox size being 960px

发布评论
评论(1)
这个条件也应该存在。
另外,如果这没有帮助,您需要等待 .tp-mainimage 加载(假设它是由 ajax 加载的)。因此,在图像加载后,您必须在那里进行 jquery 更改。
This condition should also be present.
Also, if this does not help, you'll need to wait for .tp-mainimage to load(assuming it is being loaded by ajax). So you'll have to make jquery changes there, after the image loads.