Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.css" />

<script src="https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.js"></script>

<div>
<div class="p-swiper-wrap">
  <h2 class="">Swiper8のNormalなスライダー</h2>
  <p class="">スライド数 PC:3/SP:1</p>
  <div class="p-swiper-normal">
    <div class="swiper">
      <div class="swiper-wrapper">
        <div class="swiper-slide">
          <img src="https://na2-factory.com/wordpress/wp-content/uploads/2023/04/item01-part01.jpg" width="2048" height="1365" alt="" decoding="async">
        </div>
        <div class="swiper-slide">
          <img src="https://na2-factory.com/wordpress/wp-content/uploads/2023/04/item02-part01.jpg" width="2048" height="1365" alt="" decoding="async">
        </div>
        <div class="swiper-slide">
          <img src="https://na2-factory.com/wordpress/wp-content/uploads/2023/04/item03-part01.jpg" width=" 2048" height="1365" alt="" decoding="async">
        </div>
      </div>
    </div>
    <div class="swiper-button-prev"></div>
    <div class="swiper-button-next"></div>
  </div>
  <div class="p-swiper-normal-pagi">
    <div class="swiper-pagination p-swiper-normal-pagination">
    </div>
  </div>
</div>

<div class="p-swiper-wrap">
  <h2 class="">Swiper8での両端切れるスライダー</h2>
  <p class="">スライド数 PC:3/SP:1</p>
  <div class="p-swiper-normal-2nd">
    <div class="swiper">
      <div class="swiper-wrapper">
        <div class="swiper-slide">
          <img src="https://na2-factory.com/wordpress/wp-content/uploads/2023/04/item01-part01.jpg" width="2048" height="1365" alt="" decoding="async">
        </div>
        <div class="swiper-slide">
          <img src="https://na2-factory.com/wordpress/wp-content/uploads/2023/04/item02-part01.jpg" width="2048" height="1365" alt="" decoding="async">
        </div>
        <div class="swiper-slide">
          <img src="https://na2-factory.com/wordpress/wp-content/uploads/2023/04/item03-part01.jpg" width=" 2048" height="1365" alt="" decoding="async">
        </div>

      </div>
    </div>
    <div class="swiper-button-prev"></div>
    <div class="swiper-button-next"></div>
  </div>
  <div class="p-swiper-normal-pagi-2nd">
    <div class="swiper-pagination p-swiper-normal-pagination">
    </div>
  </div>
</div>



</div>
              
            
!

CSS

              
                /* @import '@acab/reset.css'; */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:where([hidden]:not([hidden="until-found"])) {
  display: none !important;
}

:where(html) {
  -webkit-text-size-adjust: none;
  color-scheme: dark light;
}

@supports not (min-block-size: 100dvb) {
  :where(html) {
    block-size: 100%;
  }
}

@media (prefers-reduced-motion: no-preference) {
  :where(html:focus-within) {
    scroll-behavior: smooth;
  }
}

:where(body) {
  block-size: 100%;
  block-size: 100dvb;
  line-height: 1.5;
  font-family: system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

:where(input, button, textarea, select) {
  font: inherit;
  color: inherit;
}

:where(textarea) {
  resize: vertical;
  resize: block;
}

:where(button, label, select, summary, [role="button"], [role="option"]) {
  cursor: pointer;
}

:where(:disabled) {
  cursor: not-allowed;
}

:where(label:has(> input:disabled), label:has(+ input:disabled)) {
  cursor: not-allowed;
}

:where(button) {
  border-style: solid;
}

:where(a) {
  text-underline-offset: 0.2ex;
}

:where(ul, ol) {
  list-style: none;
}

:where(img, svg, video, canvas, audio, iframe, embed, object) {
  display: block;
}

:where(img, picture, svg) {
  max-inline-size: 100%;
  block-size: auto;
}

:where(p, h1, h2, h3, h4, h5, h6) {
  overflow-wrap: break-word;
}

:where(h1, h2, h3) {
  line-height: calc(1em + 0.5rem);
}

:where(hr) {
  border: none;
  border-block-start: 1px solid;
  color: inherit;
  block-size: 0;
  overflow: visible;
}

:where(:focus-visible) {
  outline: 2px solid var(--focus-color, Highlight);
  outline-offset: 2px;
}

:where(.visually-hidden:not(:focus, :active, :focus-within, .not-visually-hidden)) {
  clip-path: inset(50%) !important;
  height: 1px !important;
  width: 1px !important;
  overflow: hidden !important;
  position: absolute !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* color */
:root {
  --white: #ffffff;
  --white-a50: rgba(255, 255, 255, 0.5);

  --black: #000000;
  --black-a30: rgba(0, 0, 0, 0.3);

  --gray: #707070;

  --lit-pink: #ecb9af;
  --deep-pink: #e58573;

  --lit-pink-a30: rgba(236, 185, 175, 0.2);
  --grad-yellow-top: rgba(252, 235, 221, 1);
  --grad-yellow-mid: rgba(254, 247, 241, 1);
}

body {
  // font-family: "Noto Serif JP", serif;
  -webkit-font-smoothing: antialiased;
  text-align: justify;
  line-break: strict;
  word-break: break-all;
  overflow-wrap: break-word;
  word-wrap: break-word;
  overflow-x: hidden;
  color: var(--gray);
  background-color: var(--white);
  width: 100%;
}
/* img  */
img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  -o-object-fit: cover;
  object-fit: cover;
}

/* 以下よりSwiper */
.p-swiper-wrap {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
  margin-bottom: 80px;
}

.p-swiper-normal,
.p-swiper-normal-v9 {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: auto;
  padding: 1rem 0;
  position: relative;

  .swiper-button-prev,
  .swiper-button-next {
    color: var(--deep-pink);
  }
}
.p-swiper-normal-pagi,
.p-swiper-normal-pagi-2nd,
{
  width: 100%;
  height: 30px;
  margin: 0 auto;
  position: relative;

  .swiper-pagination {
    width: auto !important;
    position: absolute;
    top: 0;
    left: unset !important;
    right: 2rem;
    z-index: 50;
  }

  .swiper-pagination-bullet {
    width: 0.8rem;
    height: 0.8rem;
  }

  .swiper-pagination-bullet-active {
    background-color: var(--deep-pink);
  }

  .swiper-pagination-horizontal.swiper-pagination-bullets
    .swiper-pagination-bullet {
    margin: 0 8px;
  }
}

.p-swiper-normal-pagi-2nd {
  .swiper-pagination-bullet-active {
    background-color: var(--gray);
  }
}

.p-swiper-normal-2nd {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: auto;
  padding: 1rem 0;
  position: relative;

  .swiper-button-prev,
  .swiper-button-next {
    color: var(--gray);
  }
}

              
            
!

JS

              
                const initSwiper_normalType = () => {
  if (document.querySelector(".p-swiper-normal .swiper")) {
    const normal_swiper = new Swiper(".p-swiper-normal .swiper", {
      effect: "slide", 

      loop: true,
      loopAdditionalSlides: 1,
      speed: 3000,
      autoplay: {
        delay: 4000,
        // delay: 0,
        disableOnInteraction: false,
        waitForTransition: false
      },
      followFinger: true,

      slidesPerView: "1", // コンテナ内に表示させるスライド数(CSSでサイズ指定する場合は 'auto')
      spaceBetween: 40, // スライド間の余白(px)
      centeredSlides: false, // アクティブなスライドを中央に配置する

      navigation: {
        nextEl: ".p-swiper-normal .swiper-button-next", // 「次へ」ボタン要素のクラス
        prevEl: ".p-swiper-normal .swiper-button-prev" // 「前へ」ボタン要素のクラス
        // nextEl: '.swiper-button-next', // 「次へ」ボタン要素のクラス
        // prevEl: '.swiper-button-prev', // 「前へ」ボタン要素のクラス
      },
      pagination: {
        el: ".p-swiper-normal-pagi .swiper-pagination", // ページネーション要素のクラス
        // el: '.swiper-pagination', // ページネーション要素のクラス
        clickable: true, // クリックによるスライド切り替えを有効にする
        type: "bullets" // 'bullets'(デフォルト) | 'fraction' | 'progressbar'
      },

      breakpoints: {
        // ブレークポイント
        // 600: { // 画面幅600px以上で適用
        //   slidesPerView: 2,
        // },
        1024: {
          // 画面幅1024px以上で適用
          slidesPerView: 3,
          spaceBetween: 32
        },
        1200: {
          // 画面幅1200px以上で適用
          slidesPerView: 3
          // spaceBetween: 32,
        }
      }
    });
  }
};

const initSwiper_normalType2nd = () => {
  if (document.querySelector(".p-swiper-normal-2nd .swiper")) {
    const normal2nd_swiper = new Swiper(".p-swiper-normal-2nd .swiper", {
      effect: "slide", 

      loop: true,
      loopAdditionalSlides: 1,
      speed: 2000,
      autoplay: {
        delay: 4000,
        // delay: 0,
        disableOnInteraction: false,
        waitForTransition: false
      },
      followFinger: true,

      slidesPerView: "1.5", // コンテナ内に表示させるスライド数(CSSでサイズ指定する場合は 'auto')
      spaceBetween: 40, // スライド間の余白(px)
      centeredSlides: true, // アクティブなスライドを中央に配置する

      navigation: {
        nextEl: ".p-swiper-normal-2nd .swiper-button-next", // 「次へ」ボタン要素のクラス
        prevEl: ".p-swiper-normal-2nd .swiper-button-prev" // 「前へ」ボタン要素のクラス
      },
      pagination: {
        el: ".p-swiper-normal-pagi-2nd .swiper-pagination", // ページネーション要素のクラス
        clickable: true, // クリックによるスライド切り替えを有効にする
        type: "bullets" // 'bullets'(デフォルト) | 'fraction' | 'progressbar'
      },

      breakpoints: {
        // ブレークポイント
        // 600: { // 画面幅600px以上で適用
        //   slidesPerView: 2,
        // },
        1024: {
          // 画面幅1024px以上で適用
          slidesPerView: 2.5,
          spaceBetween: 32
        },
        1200: {
          // 画面幅1200px以上で適用
          slidesPerView: 2.5
          // spaceBetween: 32,
        }
      }
    });
  }
};



window.addEventListener("load", function () {
  initSwiper_normalType();

  initSwiper_normalType2nd();

});

              
            
!
999px

Console