Swiper
上下複数行のスライダー
オプションで反映スライド数と行数を指定する
・「slidesPerView」⇒横列数
・「gridのrows」⇒縦列数
【注意】行数や列数によってスライド数が足りない場合がある。空の要素にで空白になってしまう。要素の数に注意
CSS
.swiper__content {
width: min(100%, 700px);
margin: 0 auto 50px;
margin-block: 50px;
}
.swiper-slide img {
width: 100%;
height: auto;
}
.swiper {
width: 100%;
aspect-ratio: 35 / 24; //アスペクト比でサイズ指定
object-fit: cover;
}
.swiper-wrapper {
max-width: 700px;
}
.swiper-slide {
height: auto;
}
script
const swiper = new Swiper(".swiper", {
// 反映スライド数
slidesPerView: 2,
// 行数
grid: {
rows: 2,
},
spaceBetween: 10,
pagination: {
el: ".swiper-pagination",
},
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
});







