<head>
<link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css">
<script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
</head>
<div class="swiper-container">
<!-- Additional required wrapper -->
<div class="swiper-wrapper">
<!-- Slides -->
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
...
</div>
<!-- If we need pagination -->
<div class="swiper-pagination"></div>
</div>
<div class="swiper-navigation">
<button id="swiperPrev"><</button>
<button id="swiperNext">></button>
</div>
.swiper-container {
width: 600px;
height: 100px;
margin-bottom: 50px;
}
.swiper-navigation {
display: flex;
justify-content: space-between;
width: 600px;
margin: 0 auto;
}
const mySwiper = new Swiper('.swiper-container', {
// Optional parameters
loop: true,
// If we need pagination
pagination: {
el: '.swiper-pagination',
},
// Navigation arrows
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
// And if we need scrollbar
scrollbar: {
el: '.swiper-scrollbar',
},
})
const swiperPrev = document.getElementById('swiperPrev')
const swiperNext = document.getElementById('swiperNext')
swiperPrev.addEventListener('click', () => {
mySwiper.slidePrev();
})
swiperNext.addEventListener('click', () => {
mySwiper.slideNext();
})
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.