我有一个用于产品图片的旋转木马(slick.js),我试图在这些图像上实现缩放,但无论在光滑的旋转木马中哪个图像处于活动状态,我只能看到旋转木马中的最后一个图像缩放容器,这是我的代码。
HTML<ul class="image-carousel">
<li>
<img src="/image1.png" data-zoom-image="/image1-large.jpg" class="zoom">
</li>
<li>
<img src="/image2.png" data-zoom-image="/image2-large.jpg" class="zoom">
</li>
<li>
<img src="/image3.png" data-zoom-image="/image3-large.jpg" class="zoom">
</li>
<li>
<img src="/image4.png" data-zoom-image="/image4-large.jpg" class="zoom">
</li>
</ul>
JS
$(".image-carousel").slick();
$(".zoom").elevateZoom();
答案 0 :(得分:0)
更改后,
$('#slider-for').on('beforeChange', function(event, slick, currentSlide, nextSlide){
var img = $(slick.$slides[nextSlide]).find("img");
$('.zoomWindowContainer,.zoomContainer').remove();
$(img).elevateZoom();
});
页面已加载
$('#slider-for .slick-current img').elevateZoom();
这是正确的。您可以尝试。
答案 1 :(得分:-1)
您可以使用下面给出的代码。
@{
ViewBag.Title = "Contact";
Layout = null;
}
<script src="~/Scripts/jquery-1.8.3.min.js"></script>
<link href="~/Scripts/slick.css" rel="stylesheet" />
<script src="~/Scripts/slick.min.js"></script>
<script src="~/Scripts/jquery.elevatezoom.js"></script>
<ul class="image-carousel">
<li>
<img id="zoom_01" class="zoom" src="http://www.elevateweb.co.uk/wp-content/themes/radial/zoom/images/small/image2.png" data-zoom-image="http://www.elevateweb.co.uk/wp-content/themes/radial/zoom/images/large/image2.jpg" />
</li>
<li>
<img class="zoom" src="http://www.elevateweb.co.uk/wp-content/themes/radial/zoom/images/small/image3.png" data-zoom-image="http://www.elevateweb.co.uk/wp-content/themes/radial/zoom/images/large/image3.jpg" />
</li>
<li>
<img class="zoom" src="http://www.elevateweb.co.uk/wp-content/themes/radial/zoom/images/small/image4.png" data-zoom-image="http://www.elevateweb.co.uk/wp-content/themes/radial/zoom/images/large/image4.jpg" />
</li>
</ul>
<script>
$(document).ready(function () {
$(".image-carousel").slick();
$(".zoom").elevateZoom();
});
</script>