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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                %span#wrap
 -(1..2).each do |i|
  %span{:class => "inner inner#{i}"}
   -10.times do
    %span.level
     -5.times do
      .cell
%b scroll me

              
            
!

CSS

              
                html {
  scroll-behavior: smooth;
}

body{
  height:100vh;
  overflow-x:hidden;
  --color1: #17448c;
  --color2: #fa9fca;
  --color3: #fa6c4b;
  --color4: #cac8bb;
   --color5: #140f06;
  b{
    position:fixed;
    bottom:1vmin;
    z-index:10;
    width:100%;
    text-align:center;
    font-size:1.25vmin;
    color:var(--color4);
  }
  &:before, &:after{
    content:'';
    position:fixed;
    height:60vh;
    width:60vh;
    box-shadow:0 0 0 10vh #fff, 0 2vh 20vh 2vh rgba(0,0,0,0.5), 0 0 0 40vh #fff;
    left:50%;
    top:50%;
    transform:translate(-50%, -50%) translateZ(1px);
    transform-style:preserve-3d;
    pointer-events:none;
    z-index:9;
  }
  &:after{
    z-index:8;
    height:100vh;
    width:100vw;
    box-shadow:none;
    backdrop-filter:url(#warp);
    transform:translate(-50%, -50%) scale(var(--warp));
  }
  svg{
    position:absolute;
  }
}

body::-webkit-scrollbar-track
{
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
    border-radius: 0px;
    background-color: #F5F5F5;
}

body::-webkit-scrollbar
{
    width: 5px;
    background-color: #F5F5F5;
}

body::-webkit-scrollbar-thumb
{
    border-radius: 10px;
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
    background: linear-gradient(to bottom, var(--color2), var(--color3));
}


#wrap{
  position:absolute;
  width:60vh;
  height:auto;
  display:block;
  left:50%;
  z-index:0;
  transform:translateX(-50%);
  top:0;
  background:var(--color3);
  .inner{
    display: grid;
    grid-template-rows: repeat(8, 1fr);
    grid-template-columns: 1;
    grid-column-gap: 0px;
    grid-row-gap: 0px;
    width:100%;
    padding-left:0%;
    margin-left:0%;
    box-sizing:border-box;
    height:100vh;
    overflow-y:hidden;
    transform-style:preserve-3d;
    overflow:hidden;
    *{
      transform-style:preserve-3d;
      &:before, &:after{
        transform-style:preserve-3d;
      }
    }
  .level{
    position:relative;
    display:inline-block;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: 1fr;
    grid-column-gap: 0px;
    grid-row-gap: 0px;
    z-index:3;
    overflow:visible;
    @for $i from 1 through 10{
      &:nth-of-type(#{$i}){
        
    .cell{
      position:relative;
      transform:scale(1.0125);
      z-index:5;
      background:var(--color);
      @for $j from 1 through 5{
        &:nth-of-type(#{$j}){
          --cellProgress: calc(var(--progress) * #{($i * $j)/10});
        }
      }
      &.cell1, &.cell10{
        z-index:9;
        overflow:visible;
        &:before{
          content:'';
          position:absolute;
          width:50%;
          height:50%;
          left:25%;
          top:25%;
          background:linear-gradient(calc((var(--progress) * (var(--multiplier) * 2)) * 0.33deg), var(--secondaryColor), var(--color));
          border-radius:100%;
        }
        &:nth-of-type(even){
          &:before{
            transform:translateX(-100%) scale(calc(var(--multiplier)/2));
          }
        }
      }
      &.cell2, &.cell3{
        overflow:hidden;
        &:before{
          content:'';
          position:absolute;
          width:100%;
          height:100%;
          left:0;
          top:0;
          background:var(--secondaryColor);
          transform:rotate(calc(var(--multiplier) * 90deg)) translateX(calc((var(--cellProgress) * (var(--multipliser) * 2.5%))));
        }
      }
      &.cell4, &.cell9{
        &:before{
          content:'';
          position:absolute;
          width:100%;
          height:100%;
          top:0;
          left:-2.5%;
          background:linear-gradient(calc(var(--multiplier) * 45deg), var(--color), var(--secondaryColor));
          clip-path: polygon(50% 10%, 10% 75%, 90% 75%);
          transform:scale(calc(var(--multiplier)/4)) rotate(calc(var(--multiplier) * 90deg)) translateY(calc((var(--cellProgress) * var(--multiplier)) * -1%));
        }
        &:nth-of-type(odd){
          &:before{
            transform:scale(calc(var(--multiplier)/4)) translateY(calc((var(--cellProgress) * var(--multiplier)) * -1%)) rotate(calc((var(--progress) * var(--multiplier)) * 0.5deg));
          }
        }
        &:nth-of-type(even){
          &:after{
            content:'';
            width:100%;
            height:100%;
            left:0;
            top:0;
            background:var(--color);
            z-index:3;
            -webkit-mask:repeating-linear-gradient(to bottom, #000, #000 0.3vmin, transparent 0.3vmin, transparent 0.6vmin, #000 0.6vmin);
            display:block;
          }
        }
      }
      &.cell5:not(.cell6){
        overflow:hidden;
        &:before{
          content:'';
          position:absolute;
          width:100%;
          height:100%;
          left:0;
          top:0;
          background:linear-gradient(to left, var(--color), var(--secondaryColor));
          transform:rotate(calc(var(--multiplier) * 90deg)) translateX(calc((var(--cellProgress) * 2%) - 50%));
        }
        &:nth-of-type(even){
          &:before{
            border-radius:500%;
            width:90%;
            height:90%;
            left:5%;
            top:5%;
          }
        }
      }
      &.cell11{
        &:nth-of-type(odd){
          transform:scale(1.0125) scaleY(-1);
          &:before, &:after{
            bottom:0;
          }
        }
      }
      &.cell6, &.cell11{
        &:before{
          content:'';
          position:absolute;
          bottom:-2.5%;
          left:45%;
          width:5%;
          background:linear-gradient(to bottom, var(--secondaryColor), var(--color));
          border-radius:0px;
          height:1000%;
          -webkit-masK: linear-gradient(to top, #000 calc(var(--progress) * 1%), transparent calc(var(--cellProgress) * 1%));
        }
        &:nth-of-type(odd){
          &:before{
            background:linear-gradient(to top, var(--secondaryColor), var(--color));
          }
          &:after{
            content:'';
            width:100%;
            height:100%;
            left:0;
            top:0;
            background:var(--color);
            z-index:9;
            -webkit-mask:repeating-linear-gradient(45deg, #000, #000 0.3vmin, transparent 0.3vmin, transparent 0.6vmin, #000 0.6vmin);
            display:block;
          }
        }
        &:nth-of-type(even){
          &:before{
            content:'';
            position:absolute;
            left:0;
            top:45%;
            height:5%;
            background:linear-gradient(to left, var(--secondaryColor), var(--color));
            border-radius:0px;
            width:1000%;
            -webkit-masK: linear-gradient(to right, #000 calc(var(--progress) * 1%), transparent calc(var(--cellProgress) * 1%));
          }
          &:nth-of-type(4n){
            transform:scaleX(-1);
          }
        }
        
      }
      &.cell7{
        overflow:hidden;
        &:before, &:after{
          content:'';
          position:absolute;
          width:80%;
          height:80%;
          top:calc(10% + 0.75vmin);
          left:10%;
          -webkit-mask:radial-gradient(circle at center, #000 0.15vmin, transparent 0.15vmin);
          -webkit-mask-size:1.5vmin 3vmin;
          -webkit-mask-position:calc((var(--progress) * var(--multiplier)) * 0.25%) 50%;
          background:linear-gradient(to bottom, var(--secondaryColor), var(--color));
        }
        &:after{
          top:calc(10% - 0.75vmin);
          -webkit-mask-position:calc((var(--progress) * var(--multiplier)) * -0.25%) 50%;
        }
        &:nth-of-type(even){
          width:198.5%;
          left:-100%;
          z-index:9;
        }
      }
      &.cell8{
        &:before{
          content:'';
          position:absolute;
          width:calc(100% * var(--multiplier));
          height:calc(100% * var(--multiplier));
          top:0;
          left:0;
          background:radial-gradient(circle at center, var(--secondaryColor), transparent 75%);
          -webkit-mask:repeating-radial-gradient(#000 calc(1% * var(--progress)), transparent calc(1% * var(--progress)), transparent calc((1% * var(--progress)) + (8%/var(--multiplier))), #000 calc((1% * var(--progress)) + (8%/var(--multiplier))), #000 calc((1% * var(--progress)) + (11%/var(--multiplier))));
        }
        &:nth-of-type(even){
          &:before{
            transform:translateY(-50%);
          }
        }
      }
      &.cell12, &.cell13{
        background:linear-gradient(calc(var(--multiplier) * 45deg), var(--color) calc(var(--progress) * -15%), var(--secondaryColor) calc(var(--progress) * 15%));
      }
      &.cell14{
        box-shadow:inset 0 calc(var(--progress) * 15%) 4vmin 0 var(--secondaryColor);
      }
    } 
      }
    }
  }
  }
}
              
            
!

JS

              
                const wrap = document.getElementById('wrap');
const body = document.body;
let toggle = 2;

document.addEventListener("DOMContentLoaded", function(){
  var newWrap = document.getElementById("wrap");
  
 newWrap.querySelectorAll(".cell").forEach(cell => { 
            cell.style.setProperty("--color","var(--color"+((Math.floor(Math.random() * 5) + 1))+")");
   cell.classList.add("cell" + Math.floor(Math.random() * 20));
              
              cell.style.setProperty("--secondaryColor","var(--color"+((Math.floor(Math.random() * 5) + 1))+")");
              cell.style.setProperty("--multiplier", (Math.floor(Math.random() * 4) + 1));
   
            });
  newWrap.querySelectorAll(".inner").forEach(inner => { 
            inner.style.setProperty("--height", (((Math.floor(Math.random() * 20) + 1))/4) + 1);
            });
});

gsap.registerPlugin(ScrollTrigger);
 gsap.utils.toArray(".inner").forEach(function (elem) {
      gsap.fromTo(elem, {"--num": "100",}, {
        "--num": "300",
        scrollTrigger: { 
          trigger: elem,
          start: "top 100%",
          end: "top 0%",
          scrub: 12,
          ease:"power1.inOut",
          onUpdate: (self) => {
            const progVal = Math.abs((self.progress * 100) - 50);
            body.style.setProperty("--progress", progVal);
          },
          onLeave: function (){
            var newWrap = document.getElementsByClassName("inner" + toggle)[0];
            document.getElementById('wrap').appendChild(newWrap);
            newWrap.querySelectorAll(".cell").forEach(cell => { 
            for (let i = 0; i < 20; i++) {
              cell.classList.remove("cell" + i);
            };
              cell.classList.add("cell" + Math.floor(Math.random() * 20));
            cell.style.setProperty("--color","var(--color"+((Math.floor(Math.random() * 5) + 1))+")");
              cell.style.setProperty("--secondaryColor","var(--color"+((Math.floor(Math.random() * 5) + 1))+")");
              cell.style.setProperty("--multiplier", (Math.floor(Math.random() * 4) + 1));
            });
            ScrollTrigger.refresh();
            if (toggle == 1){
              toggle = 2;
            }
            else{
              toggle = 1;
            }
        },
        }
      });
    });


              
            
!
999px

Console