<div class="swiper">
<div class="swiper-container slider">
<div class="swiper-wrapper">
<div class="swiper-slide slide1">
<p>スライド1</p>
</div>
<div class="swiper-slide slide2">
<p>スライド2</p>
</div>
<div class="swiper-slide slide3">
<p>スライド3</p>
</div>
<div class="swiper-slide slide4">
<p>スライド4</p>
</div>
<div class="swiper-slide slide5">
<p>スライド5</p>
</div>
<div class="swiper-slide slide6">
<p>スライド6</p>
</div>
</div>
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
</div>
<div class="swiper-container swiper-thumbnail">
<div class="swiper-wrapper">
<div class="swiper-slide slide1">
<p>スライド1</p>
</div>
<div class="swiper-slide slide2">
<p>スライド2</p>
</div>
<div class="swiper-slide slide3">
<p>スライド3</p>
</div>
<div class="swiper-slide slide4">
<p>スライド4</p>
</div>
<div class="swiper-slide slide5">
<p>スライド5</p>
</div>
<div class="swiper-slide slide6">
<p>スライド6</p>
</div>
</div>
</div>
</div>
/*コンテナ要素のスタイル*/
.swiper {
display: flex;
flex-flow: column nowrap;
gap: 16px;
height: 300px;
width: 100%;
}
.swiper-container {
overflow: hidden;
width: 100%;
}
/*各スライドのスタイル*/
.swiper-slide {
flex-flow: column nowrap;
/*テキストの位置調整*/
display: flex;
justify-content: center;
align-items: center;
/*テキストの色と太さを指定*/
color: #212121;
font-weight: bold;
font-size: max(0.5rem, 1.5vw);
}
/*各スライドの背景色の設定*/
.slide1 {
background-color: #c8e6c9;
}
.slide2 {
background-color: #80cbc4;
}
.slide3 {
background-color: #4db6ac;
}
.slide4 {
background-color: #26a69a;
}
.slide5 {
background-color: #009688;
}
.slide6 {
background-color: #00897b;
}
/* スライダーのスタイル */
.slider {
position: relative;
width: 100%;
flex-grow: 1;
}
/* サムネイルのスタイル */
.swiper-thumbnail {
height: 50px;
}
.swiper-thumbnail .swiper-wrapper {
flex-direction: row;
}
/*アクティブなときのスタイル*/
.swiper-thumbnail .swiper-slide {
flex-flow: row nowrap;
cursor: pointer;
opacity: 0.2;
transition: opacity 0.5s;
}
.swiper-thumbnail .swiper-slide.swiper-slide-thumb-active {
opacity: 1;
}
/*矢印ボタンの色を変更*/
.swiper-button-next,
.swiper-button-prev {
color: #212121;
}
/*PCサイズのスタイル*/
@media (min-width: 599px) {
.swiper {
flex-flow: row nowrap;
}
.swiper-thumbnail {
width: 40%;
height: 100%;
}
.swiper-thumbnail .swiper-wrapper {
flex-direction: column;
}
.swiper-thumbnail .swiper-slide {
flex-flow: column nowrap;
}
}
const swiperThumbnail = new Swiper(".swiper-thumbnail", {
spaceBetween: 16,
slidesPerView: 3,
centeredSlides: true,
centeredSlidesBounds: true,
watchSlidesProgress: true,
breakpoints: {
599: {
direction: "vertical"
}
}
});
const slider = new Swiper(".slider", {
spaceBetween: 16,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev"
},
autoplay: true,
loop: true,
thumbs: {
swiper: swiperThumbnail
}
});