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

              
                <!--スライダー-->
<div class="swiper">
  <div class="slider swiper-container">
    <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>
<!-- サムネイル -->
<div class="swiper-thumbnail swiper-container">
  <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>
              
            
!

CSS

              
                /*コンテナ要素のスタイル*/
.swiper-container {
  width: 100%;
  height: 200px;
  margin: 0.5rem auto;
  overflow: hidden;
}

/*各スライドのスタイル*/
.swiper-slide {
  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;
}

/*サムネイルのスタイル*/
.swiper-thumbnail {
  height: 50px;
}

.swiper-thumbnail .swiper-slide {
  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;
}

              
            
!

JS

              
                //定義する順番に注意
// サムネイル
const swiperThumbnail = new Swiper(".swiper-thumbnail", {
  spaceBetween: 10, //スライド感の余白
  slidesPerView: 3, //一度に表示するスライド枚数
  watchSlidesProgress: true //スライダーの動きにスライドを追従させる
});
// スライダー
const slider = new Swiper(".slider", {
  navigation: {
    nextEl: ".swiper-button-next",
    prevEl: ".swiper-button-prev"
  },
  autoplay: true,
  loop: true,
  thumbs: {
    swiper: swiperThumbnail //連動したいスライダー(swiperThumbnailを指定する)
  }
});

              
            
!
999px

Console