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

              
                    <ul class="photo-list">
        <li class="photo scr-target anime__fadeIn">
            <img src="https://picsum.photos/350/350">
            <p>フェードイン</p>
        </li>
        <li class="photo scr-target anime__fadeInDown">
            <img src="https://picsum.photos/350/350">
            <p>フェードイン(上から)</p>
        </li>
        <li class="photo scr-target anime__fadeInUp">
            <img src="https://picsum.photos/350/350">
            <p>フェードイン(下から)</p>
        </li>
        <li class="photo scr-target anime__fadeInLeft">
            <img src="https://picsum.photos/350/350">
            <p>フェードイン(左から)</p>
        </li>
        <li class="photo scr-target anime__fadeInRight">
            <img src="https://picsum.photos/350/350">
            <p>フェードイン(右から)</p>
        </li>
        <li class="photo scr-target anime__zoomIn">
            <img src="https://picsum.photos/350/350">
            <p>ズームイン</p>
        </li>
        <li class="photo scr-target anime__zoomOut">
            <img src="https://picsum.photos/350/350">
            <p>ズームアウト</p>
        </li>
    </ul>

<!-- IE対応↓ -->
<script src="https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver"></script>
<!-- IE対応↑ -->
              
            
!

CSS

              
                img {
    max-width: 100%;
}
.photo-list {
    padding: 500px 0;
    width: 90%;
    max-width: 1000px;
    margin: 0 auto;
}
.photo-list li {
    width: 300px;
    margin: 0 auto 100px;
}

/* アニメーション設定 */
.scr-target {
    /* アニメーション開始から終了までの所要時間 */
    -webkit-animation-duration: 1s;
    animation-duration: 1s;
    /* アニメーションが開始するまでの遅延時間 */
    -webkit-animation-delay: 0s;
    animation-delay: 0s;
    /* アニメーションのループ回数 - infiniteで無限ループ */
    -webkit-animation-iteration-count: 1;
    animation-iteration-count: 1;
    /* キーフレームアニメーションで指定したプロパティをアニメーション開始前、終了後に適用するかどうか */
    -webkit-animation-fill-mode: both;
    animation-fill-mode: both;
}
.scr-target[class*='fadeIn'],
.scr-target[class*='zoom'] {
    opacity: 0;
}

/* フェードイン */
@-webkit-keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}
.anime__fadeIn.is-active {
    -webkit-animation-name: fadeIn;
    animation-name: fadeIn;
}

/* フェードイン(上から) */
@-webkit-keyframes fadeInDown {
    from {
        opacity: 0;
        -webkit-transform: translate3d(0, -100%, 0);
        transform: translate3d(0, -100%, 0);
    }

    to {
        opacity: 1;
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
}
@keyframes fadeInDown {
    from {
        opacity: 0;
        -webkit-transform: translate3d(0, -100%, 0);
        transform: translate3d(0, -100%, 0);
    }

    to {
        opacity: 1;
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
}
.anime__fadeInDown.is-active {
    -webkit-animation-name: fadeInDown;
    animation-name: fadeInDown;
}

/* フェードイン(下から) */
@-webkit-keyframes fadeInUp {
    from {
        opacity: 0;
        -webkit-transform: translate3d(0, 100%, 0);
        transform: translate3d(0, 100%, 0);
    }

    to {
        opacity: 1;
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
}
@keyframes fadeInUp {
    from {
        opacity: 0;
        -webkit-transform: translate3d(0, 100%, 0);
        transform: translate3d(0, 100%, 0);
    }

    to {
        opacity: 1;
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
}
.anime__fadeInUp.is-active {
    -webkit-animation-name: fadeInUp;
    animation-name: fadeInUp;
}

/* フェードイン(左から) */
@-webkit-keyframes fadeInLeft {
    from {
        opacity: 0;
        -webkit-transform: translate3d(-100%, 0, 0);
        transform: translate3d(-100%, 0, 0);
    }

    to {
        opacity: 1;
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
}
@keyframes fadeInLeft {
    from {
        opacity: 0;
        -webkit-transform: translate3d(-100%, 0, 0);
        transform: translate3d(-100%, 0, 0);
    }

    to {
        opacity: 1;
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
}
.anime__fadeInLeft.is-active {
    -webkit-animation-name: fadeInLeft;
    animation-name: fadeInLeft;
}

/* フェードイン(右から) */
@-webkit-keyframes fadeInRight {
    from {
        opacity: 0;
        -webkit-transform: translate3d(100%, 0, 0);
        transform: translate3d(100%, 0, 0);
    }

    to {
        opacity: 1;
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
}
@keyframes fadeInRight {
    from {
        opacity: 0;
        -webkit-transform: translate3d(100%, 0, 0);
        transform: translate3d(100%, 0, 0);
    }

    to {
        opacity: 1;
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
}
.anime__fadeInRight.is-active {
    -webkit-animation-name: fadeInRight;
    animation-name: fadeInRight;
}

/* ズームイン */
@-webkit-keyframes zoomIn {
    from {
        opacity: 0;
        -webkit-transform: scale3d(0.3, 0.3, 0.3);
        transform: scale3d(0.3, 0.3, 0.3);
    }

    100% {
        opacity: 1;
    }
}
@keyframes zoomIn {
    from {
        opacity: 0;
        -webkit-transform: scale3d(0.3, 0.3, 0.3);
        transform: scale3d(0.3, 0.3, 0.3);
    }

    100% {
        opacity: 1;
    }
}
.anime__zoomIn.is-active {
    -webkit-animation-name: zoomIn;
    animation-name: zoomIn;
}

/* ズームアウト */
@-webkit-keyframes zoomOut {
    from {
        opacity: 0;
        -webkit-transform: scale3d(1.6, 1.6, 1.6);
        transform: scale3d(1.6, 1.6, 1.6);
    }
    100% {
        opacity: 1;
    }
}
@keyframes zoomOut {
    from {
        opacity: 0;
        -webkit-transform: scale3d(1.6, 1.6, 1.6);
        transform: scale3d(1.6, 1.6, 1.6);
    }
    100% {
        opacity: 1;
    }
}
.anime__zoomOut.is-active {
    -webkit-animation-name: zoomOut;
    animation-name: zoomOut;
}

              
            
!

JS

              
                window.addEventListener("load", function() {
const target = document.querySelectorAll('.scr-target')
const targetArray = Array.prototype.slice.call(target);
const options = {
    root: null,
    rootMargin: '0px 0px',
    threshold: 0.5
};

const observer = new IntersectionObserver(callback, options)
targetArray.forEach(function (tgt) {
  observer.observe(tgt)
});

function callback(entries) {
  entries.forEach(function(entry, i) {
    const target = entry.target;
    if (entry.isIntersecting && !target.classList.contains('is-active')) {
        target.classList.add('is-active');
    }
  });
};
});

              
            
!
999px

Console