<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.css" />
<style>
*{margin: 0;padding: 0;font: inherit;color: inherit;list-style: none;}
.main-slide{
height: 500px;
}
.main-slide .swiper-slide{
display: flex;
align-items: center;
justify-content: center;
background: #ccc;
font-size: 10vw;
}
.main-slide .btn{
position: absolute;
width: 50px;
height: 50px;
background: #f00;
top: 50%;
transform: translateY(-50%);
z-index: 1;
}
.main-slide .btn.prev{left: 10px;}
.main-slide .btn.next{right: 10px;}
</style>
</head>
<body>
<div class="swiper main-slide">
<div class="swiper-wrapper">
<div class="swiper-slide">1</div>
<div class="swiper-slide">2</div>
<div class="swiper-slide">3</div>
<div class="swiper-slide">4</div>
<div class="swiper-slide">5</div>
</div>
<a href="" class="btn prev">이전</a>
<a href="" class="btn next">다음</a>
<div class="swiper-pagination"></div>
</div>
<script src="https://code.jquery.com/jquery-3.6.3.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.js"></script>
<script>
$(function(){
const mainSlide = new Swiper(".main-slide",{
slidesPerView:2,
spaceBetween:10,
navigation:{
nextEl:".next",
prevEl:".prev",
},
pagination:{
el:".swiper-pagination"
},
on:{
"init":function(){
},
"slideChange":function(){
console.log((this.activeIndex+1)+'/'+this.slides.length);
}
}
})
})
</script>
</body>
</html>