<!-- Sliderを包むコンテナ要素 -->
<div id="swiper01" 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 class="swiper-slide slide4">
      <p>slide4</p>
    </div>
    <div class="swiper-slide slide5">
      <p>slide5</p>
    </div>
    <div class="swiper-slide slide6">
      <p>slide6</p>
    </div>
  </div>
  <div class="swiper-button-prev"></div>
  <div class="swiper-button-next"></div>
  <div class="swiper-scrollbar"></div>
</div>
.swiper {
  /*スライダーの幅と高さを調整*/
  width: 100%;
  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: #c8e6c9;
}

.slide2 {
  background-color: #80cbc4;
}

.slide3 {
  background-color: #4db6ac;
}
.slide4 {
  background-color: #26a69a;
}

.slide5 {
  background-color: #009688;
}

.slide6 {
  background-color: #00897b;
}
const swiper01 = new Swiper("#swiper01", {
  navigation: {
    nextEl: ".swiper-button-next",
    prevEl: ".swiper-button-prev"
  },
  autoplay: true,
  slidesPerView: 1,
  breakpoints: {
    // 599px以上の場合
    599: {
      slidesPerView: 2
    },
    // 1024px以上の場合
    1024: {
      slidesPerView: 3
    }
  }
});

External CSS

  1. https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.css

External JavaScript

  1. https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.js