<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
<div class="swiper-slide">Slide 4</div>
<div class="swiper-slide">Slide 5</div>
<div class="swiper-slide">Slide 6</div>
<div class="swiper-slide">Slide 7</div>
<div class="swiper-slide">Slide 8</div>
<div class="swiper-slide">Slide 9</div>
<div class="swiper-slide">Slide 10</div>
<div class="swiper-slide">Slide 11</div>
<div class="swiper-slide">Slide 12</div>
<div class="swiper-slide">Slide 13</div>
<div class="swiper-slide">Slide 14</div>
<div class="swiper-slide">Slide 15</div>
<div class="swiper-slide">Slide 16</div>
<div class="swiper-slide">Slide 17</div>
<div class="swiper-slide">Slide 18</div>
<div class="swiper-slide">Slide 19</div>
<div class="swiper-slide">Slide 20</div>
</div>
<div class="swiper-pagination"></div>
</div>
html, body {
position: relative;
height: 100%;
overflow: hidden;
}
body {
background: #eee;
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
font-size: 14px;
color:#000;
margin: 0;
padding: 0;
}
.swiper-container {
width: 100%;
height: 100%;
margin-left: auto;
margin-right: auto;
}
.swiper-slide {
text-align: center;
font-size: 18px;
background: #fff;
height: 100%;
opacity: 0.3;
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;
transition: .3s all;
}
.swiper-slide_active {
opacity: 1;
background-color: orange;
}
var swiper = new Swiper(".swiper-container", {
slidesPerView: 6,
spaceBetween: 30,
loop: true,
pagination: {
el: ".swiper-pagination",
clickable: true
},
on: {
init: function () {
swiperClassHandler (this.activeIndex, '.swiper-slide')
},
slideChange: function () {
swiperClassHandler (this.activeIndex, '.swiper-slide')
},
},
});
function swiperClassHandler (i, csl) {
let sliders = document.querySelectorAll(csl);
sliders.forEach(n => n.classList.remove('swiper-slide_active'));
console.log(sliders);
Array.prototype.slice.call(sliders, i + 2 , i + 4).forEach(n => n.classList.add('swiper-slide_active'));
}