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="images">
  <div class="images__inner">
      <div class="images__flex">
          <div class="images__grid">
              <img src="https://picsum.photos/200/500" alt="">
              <img src="https://picsum.photos/300/300" alt="">
              <img src="https://picsum.photos/300/200" alt="">
              <img src="https://picsum.photos/500/500" alt="">
              <img src="https://picsum.photos/200/200" alt="">
              <img src="https://picsum.photos/200/300" alt="">
          </div>
          <div class="images__grid">
              <img src="https://picsum.photos/200/500" alt="">
              <img src="https://picsum.photos/300/300" alt="">
              <img src="https://picsum.photos/300/200" alt="">
              <img src="https://picsum.photos/500/500" alt="">
              <img src="https://picsum.photos/200/200" alt="">
              <img src="https://picsum.photos/200/300" alt="">
          </div>
      </div>
  </div>
</div>
              
            
!

CSS

              
                *{
    padding: 0;
    margin: 0;
}
.images{
    width: 100%;
    padding: 100vh 0 100vh;
    overflow: hidden;// 画像たちがはみ出た分を非表示
    &__inner{
        width: fit-content;
    }
    &__flex{
        width: fit-content;
        display: flex;
    }
    &__grid{
        width: fit-content;
        margin: 0 auto;
        display: grid;
        gap: 20px;
        grid-template-columns: 200px 300px 500px 200px;
        grid-template-rows: 200px 100px 200px;
        padding: 0 10px;
        img{
            display: block;
            border-radius: 20px;
            overflow: hidden;
            width: 100%;
            height: 100%;
        }
        img:nth-of-type(1){
            grid-column: 1/2;
            grid-row: 1/4;
        }
        img:nth-of-type(2){
            grid-column: 2/3;
            grid-row: 1/3;
        }
        img:nth-of-type(3){
            grid-column: 2/3;
            grid-row: 3/4;
        }
        img:nth-of-type(4){
            grid-column: 3/4;
            grid-row: 1/4;
        }
        img:nth-of-type(5){
            grid-column: 4/5;
            grid-row: 1/2;
        }
        img:nth-of-type(6){
            grid-column: 4/5;
            grid-row: 2/4;
        }
    }
}
              
            
!

JS

              
                /* 透明な状態から大きさを変えながら出現*/
gsap.fromTo('.images__grid img',{autoAlpha:0,scale:.7},{autoAlpha:1,scale:1,scrollTrigger:{
    trigger:'.images__flex',
    start:'top center',
    toggleActions:'play none none reverse'
}});
/* トリガー位置に到達したら画像を囲む要素が元の位置に戻る */
gsap.fromTo('.images__flex',{x:200},{x:0,scrollTrigger:{
    trigger:'.images__flex',
    start:'top center',
    toggleActions:'play none none reverse'
}});
/* スクロールに応じて画像を囲む要素が左に移動 */
gsap.to('.images__inner',{x:-200,scrollTrigger:{
    trigger:'.images__flex',
    start:'top center',
    scrub:true,
    markers:true,
}});

              
            
!
999px

Console