<!-- Sliderを包むコンテナ要素 -->
<div id="fade" class="swiper">
<!-- スライド要素を包む要素 -->
<div class="swiper-wrapper">
<!-- 各スライド -->
<div class="swiper-slide slide1">
<p>fade</p>
</div>
<div class="swiper-slide slide2">
<p>fade</p>
</div>
<div class="swiper-slide slide3">
<p>fade</p>
</div>
</div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
<div id="cube" class="swiper">
<!-- スライド要素を包む要素 -->
<div class="swiper-wrapper">
<!-- 各スライド -->
<div class="swiper-slide slide1">
<p>cube</p>
</div>
<div class="swiper-slide slide2">
<p>cube</p>
</div>
<div class="swiper-slide slide3">
<p>cube</p>
</div>
</div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
<div id="coverflow" class="swiper">
<!-- スライド要素を包む要素 -->
<div class="swiper-wrapper">
<!-- 各スライド -->
<div class="swiper-slide slide1">
<p>coverflow</p>
</div>
<div class="swiper-slide slide2">
<p>coverflow</p>
</div>
<div class="swiper-slide slide3">
<p>coverflow</p>
</div>
</div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
<div id="flip" class="swiper">
<!-- スライド要素を包む要素 -->
<div class="swiper-wrapper">
<!-- 各スライド -->
<div class="swiper-slide slide1">
<p>flip</p>
</div>
<div class="swiper-slide slide2">
<p>flip</p>
</div>
<div class="swiper-slide slide3">
<p>flip</p>
</div>
</div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
<div id="cards" class="swiper">
<!-- スライド要素を包む要素 -->
<div class="swiper-wrapper">
<!-- 各スライド -->
<div class="swiper-slide slide1">
<p>cards</p>
</div>
<div class="swiper-slide slide2">
<p>cards</p>
</div>
<div class="swiper-slide slide3">
<p>cards</p>
</div>
</div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
<div id="creative" class="swiper">
<!-- スライド要素を包む要素 -->
<div class="swiper-wrapper">
<!-- 各スライド -->
<div class="swiper-slide slide1">
<p>creative</p>
</div>
<div class="swiper-slide slide2">
<p>creative</p>
</div>
<div class="swiper-slide slide3">
<p>creative</p>
</div>
</div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
.swiper {
/*スライダーの幅と高さを調整*/
width: 90%;
height: 170px;
margin: 1rem 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;
}
const fade = new Swiper("#fade", {
loop: true,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev"
},
effect: "fade"
});
const cube = new Swiper("#cube", {
loop: true,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev"
},
effect: "cube"
});
const coverflow = new Swiper("#coverflow", {
loop: true,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev"
},
effect: "coverflow"
});
const flip = new Swiper("#flip", {
loop: true,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev"
},
effect: "flip"
});
const cards = new Swiper("#cards", {
loop: true,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev"
},
effect: "cards"
});
const creative = new Swiper("#creative", {
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev"
},
grabCursor: true,
effect: "creative",
creativeEffect: {
prev: {
shadow: true,
translate: ["-125%", 0, -800],
rotate: [0, 0, -90]
},
next: {
shadow: true,
translate: ["125%", 0, -800],
rotate: [0, 0, 90]
}
}
});