<!-- Sliderを包むコンテナ要素 -->
<div class="swiper">
<!-- スライド要素を包む要素 -->
<div class="swiper-wrapper">
<!-- 各スライド -->
<div class="swiper-slide slide1">
<p>slide1</p>
</div>
<div class="swiper-slide slide2">
<p>slide2</p>
</div>
<div class="swiper-slide slide3">
<p>slide3</p>
</div>
</div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
<div class="swiper-pagination"></div>
</div>
.swiper {
/*スライダーの幅と高さを調整*/
width: 90%;
height: 200px;
margin: 0.5rem auto;
}
.swiper-slide {
/*スライド要素の幅と高さを調整*/
width: 100%;
height: 100%;
/*テキストの位置調整*/
display: flex;
justify-content: center;
align-items: center;
/*テキストの色と太さを指定*/
color: #fff;
font-weight: bold;
}
/*各スライドの背景色の設定*/
.slide1 {
background-color: #88acbd;
}
.slide2 {
background-color: #99cb1f;
}
.slide3 {
background-color: #e43a47;
}
/* 前へ次への矢印カスタマイズ */
.swiper-button-prev:after,
.swiper-button-next:after {
content: "";
width: 1rem;
height: 1rem;
border: 0;
border-top: solid 0.5rem #f5b2b2;
border-right: solid 0.5rem #f5b2b2;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
/* 前への矢印カスタマイズ */
.swiper-button-prev:before {
border-bottom: 20px solid transparent;
border-right: 30px solid #ff4500;
border-top: 20px solid transparent;
}
.swiper-button-prev:after {
transform: rotate(-135deg);
}
/* 次への矢印カスタマイズ */
.swiper-button-next:before {
border-bottom: 20px solid transparent;
border-left: 30px solid #ff4500;
border-top: 20px solid transparent;
}
.swiper-button-next:after {
transform: rotate(45deg);
}
const swiper = new Swiper(".swiper", {
// ページネーション
pagination: {
el: ".swiper-pagination",
clickable: true
},
// 前後の矢印
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev"
}
});