Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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

Save Automatically?

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="slider">
          <div class="slider-img slider-img-01">
          </div>
          <div class="slider-img slider-img-02">
          </div>
          <div class="slider-img slider-img-03">
          </div>
        </div>
              
            
!

CSS

              
                  .slider {
    width: 100%;
    height: 500px;
    margin-left: auto;
    margin-right: auto;
    overflow: hidden;
    padding: 0;
    margin: 0;
  }
/*スライドは背景画像にする*/
  .slider-img {
    content: "";
    background-repeat: no-repeat;
    background-size: 100%;
    background-position: center;
    width: 100%;
    height: 300px;/*スライド画像の高さ*/
  }
/*スライダー画像を指定*/
  .slider-img-01 {
    background-image: url(https://kasumiblog.xsrv.jp/codepen/images/clouds.jpg);
  }
  .slider-img-02 {
    background-image: url(https://kasumiblog.xsrv.jp/codepen/images/forest.jpg);
  }
  .slider-img-03 {
    background-image: url(https://kasumiblog.xsrv.jp/codepen/images/ocean.jpg);
  }
  .slick-list {
    width: 100%;
  }
@keyframes fadezoom {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(1.1); /* 拡大率 */
  }
}
.add-zoom {
  animation: fadezoom 10s 0s forwards;
}
              
            
!

JS

              
                $(function() {
  $(".slider")
    // 現在のスライドに"add-zoom"のclassを付与(data-slick-index="0"が現在のスライド)
    .on("init", function() {
      $('.slick-slide[data-slick-index="0"]').addClass("add-zoom");
    })
    .slick({
      autoplay: true,
      fade: true, 
      arrows: false,
      speed: 2000, // スライド、フェードアニメーションの速度
      autoplaySpeed: 3000, // 自動再生の切り替え速度
      pauseOnFocus: false,
      pauseOnHover: false,
    })
    .on({
      // スライドが移動する前に発生するイベント
      beforeChange: function(event, slick, currentSlide, nextSlide) {
        // 現在のスライドに"add-zoom"のclassを付与
        $(".slick-slide", this).eq(nextSlide).addClass("add-zoom");
        // "add-zoom"のclassを消すための"remove-zoom"classを付与
        $(".slick-slide", this).eq(currentSlide).addClass("remove-zoom");
      },
      // スライドが移動した後に発生するイベント
      afterChange: function() {
        // 現在のスライド以外は"add-zoom"のclassを削除
        $(".remove-zoom", this).removeClass(
          "remove-zoom add-zoom"
        );
      },
    });
});
              
            
!
999px

Console