您好,我的 div 中有几张大图像和一张小放大镜图像,我希望将其动态定位在每个图像的右上角。我的大图像通过点击它们来切换。它们的尺寸不同。现在我正在尝试手动获取每个图像的高度和宽度并定位小图像 - 有没有办法更好地做到这一点?
小放大镜图像比大放大镜图像具有更高的 z-index。
我的查询代码:
        $('img.small').fadeOut('fast', function() {
        $('img.small').css('top',$(el).find('img.big:last').height()+60); // i want to change this
        $('img.small').css('top',$(el).find('img.big:last').width()+60); // and this
        $('img.small').fadeIn(); 
        });
我的CSS:
 #myGallery {
   width: 100%;
   height: 300px;
  }
.small img{
position: absolute;
left:150px;
top:150px;
z-index: 15000;
width: 35px;
height: 35px;   
}
我的 HTML:
<div id="myGallery" class="spacegallery">   
<img class="small" src="small.jpg" alt=""  />   
<img class="big" src=images/bw1.jpg alt=""  />
<img class="big" src=images/bw2.jpg alt=""  />
<img class="big" src=images/bw3.jpg alt=""  />
            </div>
谢谢!