Здравствуйте! Скопировал код из демо свайпера (с миниатюрами внизу). Поменял и добавил свои классы, по стилям всё встало как нужно, но инициализация почему-то не происходит. В консоли всё чисто.
JS:
var photo = new Swiper(".myPhoto", {
loop: true,
spaceBetween: 29,
slidesPerView: 3,
freeMode: true,
watchSlidesProgress: true,
});
var photo2 = new Swiper(".myPhoto2", {
loop: true,
spaceBetween: 10,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
thumbs: {
photo: {
el: '.photo'
}
},
});
HTML
<code lang="html">
<div
style="--swiper-navigation-color: #fff; --swiper-pagination-color: #fff"
class="photo myPhoto2 swiper mySwiper2"
>
<div class="photo-wrapper swiper-wrapper">
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-1.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-2.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-3.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-4.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-5.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-6.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-7.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-8.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-9.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-10.jpg" />
</div>
</div>
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
</div>
<div thumbsSlider="" class="photo myPhoto swiper mySwiper">
<div class="photo-wrapper swiper-wrapper">
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-1.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-2.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-3.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-4.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-5.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-6.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-7.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-8.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-9.jpg" />
</div>
<div class="photo-slide swiper-slide">
<img src="https://swiperjs.com/demos/images/nature-10.jpg" />
</div>
</div>
</div>
</code>
CSS
.photo {
width: 80%;
height: 300px;
}
.photo-slide {
text-align: center;
font-size: 18px;
background: #fff;
/* Center slide text vertically */
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
.photo-slide img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
.photo {
width: 100%;
height: 300px;
margin-left: auto;
margin-right: auto;
}
.photo-slide {
background-size: cover;
background-position: center;
}
.myPhoto2 {
height: 80%;
width: 100%;
}
.myPhoto {
height: 140px;
box-sizing: border-box;
padding: 10px 0;
}
.myPhoto .photo-slide {
width: 185px;
height: 141px;
opacity: 0.4;
}
.myPhoto .photo-slide-thumb-active {
opacity: 1;
}
.photo-slide img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
.fancybox__gallery {
display: flex;
flex-direction: column;
height: 460px;
margin-right: 32px;
}