<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 class="counter">
</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: 50%;
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;
}
.counter {
position: absolute;
left: 5%;
top: 5%;
z-index: 100;
font-size: 10vw;
font-weight: bold;
pointer-events: none;
display: flex;
justify-content: center;
align-items: flex-start;
}
.counter__total {
font-size: 0.5em;
margin-top: .2em;
}
var swiper = new Swiper(".swiper-container", {
slidesPerView: 1,
loop: false,
init: false,
spaceBetween: 30,
pagination: {
el: ".swiper-pagination",
clickable: true
}
});
swiper.on("slideChange afterInit init", function () {
let currentSlide = this.activeIndex + 1;
document.querySelector('.counter').innerHTML = `
<span class="counter__current">
${currentSlide < 10 ? '0' + currentSlide : currentSlide}
</span>
/
<span class="counter__total">
${this.slides.length}
</span>`;
});
swiper.init();