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

              
                <section class="intro" data-animate-perspective>
  <div class="background"></div>
  <h1 aria-label="Experiments with 3D text in HTML">
    <span>Experiments with</span>
    <span class="word" aria-hidden="true" data-animation="intro">3D Text</span>
    <span> in HTML </span>
  </h1>
  <svg class="down-arrow" title="An arrow pointing down" viewBox="0 0 448 512" width="50">
    <path d="M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z" />
  </svg>
</section>

<section class="boing" >
  <div class="background"><div class="sunburst"></div></div>
  <h2 class="word" data-animation="boing">Boing!</h2>
  <p class="sr-only">Animation description: The heading starts in 2D with the dark grey word on a plain light grey background. As the word passes half way up the screen the letters all spring forward with each letter changing to a different color. The background changes to a rotating pink sunburst.</p>
</section>

<section class="oreo" data-animate-perspective>
  <div class="background"></div>
  <h2 class="word" data-animation="oreo">Oreos</h2>
  <p class="sr-only">Animation description: The letters a colored like an Oreo and start stacked together vertically, as if inside their packaging. As the page scrolls down the letters fall into their positions side by side. </p>
</section>

<section class="slide">
  <div class="background"></div>
  <h2 class="word" data-animation="slide">Slide out</h2>
  <p class="sr-only">Animation description: The heading starts in 2D with the letters all colored light grey. As the word passes half way up the screen the letters all smoothly slide forward to float above the page revealing they are 3D. Each letter changing to a different color.</p>
</section> 

<section class="hulk" data-animate-perspective>
  <div class="background">
    <div class="cracks">
      <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1831 939" width="1831" height="939" fill="none">
        <defs>
          <g id="smoke">
            <circle cx="77.5" cy="141.5" r="77.5" fill="#A48DA955" />
            <circle cx="77.5" cy="60.5" r="60.5" fill="#A48DA955" />
            <circle cx="137.5" cy="99.5" r="77.5" fill="#A48DA955" />
          </g>
        </defs>
        <path class="crack-1" fill="#45254B" fill-rule="evenodd" d="M591.357 538.091 608.5 529l45 17.5 186.5 36 46-58.5 31.538 6.363L863.5 492 920 379.5v-18l-21.5-37H852l52.5-8.5 24.5 45.5v26L883.5 497l60.753 38.789L1032 556l82.5-27 98.5 27 9-9.5 60-11 21.1 3.388 45.12-8.224L1360 379.5l-47.5-74.5 9.5-80v80l59.5 74.5-20.79 148.886L1494.5 504l154.5 29.5L1803 403l-154 160.5-154.5-49-172.57 27.413 28.57 4.587 39.5 9.5h-52.5l-55.5-9.5-9.58 3.586L1381.5 652.5l57 42 56-11 53.5-43-53.5 54-56 18L1373 666l-122.18-107.833-46.32 17.333-14.36-6.358L1212.5 696l-9.5 120-1-126.5-29.27-128.067L1139 546.5h-33l-74 19-146-30-46 65.5-35.598-6.599L846 712.5 818 766l28 40-36.5-40 17-49-32.292-124.489-139.428-25.847L605.5 694.5l30.5 28-30.5-16H583l39 29 14 80.5-20-70-45.5-33.5-43.5 38-6 65.5 16.5 43.5-22 31.5 11.5-27-18.5-48-49 14.5 49-24.5 7-60 42-44 35-7.5 27.616-135.741L608.5 556 567 575.5l-1.655-.667L354 650l-47.5-9.5H354l193.036-73.041-9.829-3.959H229l-50.5 95-92 26.5 80.5-34.5 43.5-87L142 510l-2-59.5-139.5-15H158V504l38.5 29.5 26 16h84l207.77 4.761L495 546.5h80.5l5.711-3.029L605.5 337.5l-106-157L521 121l23-38.5-33 98 33 50.5 80 106.5-32.643 200.591Z" clip-rule="evenodd"/>
        <path class="crack-1" fill="#45254B" fill-rule="evenodd" d="M520.5 122 547 42.5 530.5 0 556 42.5 530.5 122h-10Zm153 210L617 357.5l-3.5 16.5 60.5-29 38.5 16.5-31-19 3.5-41h41l31.5-31.5-10.5-24.5 3 20-24 25.5h-41l4-74-15.5 115ZM478.554 548.387 453.5 556.5 413 568l87.967 38.936L470 676.5 387.5 717l89-37 44.5-76.848L577 585l61 10 49.03 5.91-13.53 40.59L689 745l-4-68.5 27.5 20.5v20l7-27-38-28 3.5-20.5 24.511-37.88L750 608.5l94.5 17 51-69 16.294 4.3-11.294 29.7 10.5 35 35.5 42.5-16.5 97.5 29 2.5-23-8 19.5-98-36.5-43.5-5-33.5 15.146-19.621L1003.5 585l79.5-17 95 17 64.84-10.159L1264.5 609l-16 71 8.5 31.5V675l16.5-71-19.12-30.968L1286.5 568h61l86-11.5 46 28.5 47-17h-47l-46-45.5-108-18.5-52.47 17.409-34.53-79.909-60.5-29-8.5-34 3.5 44.5 59 26 30.46 75.915-43.96 14.585-71-35.5-118.5 52.5-82.307-39.283L982 470l-4-47 51-31 26 7-26-15-58 33 4 46-36.628 50.246L919 504l-95 35.5h-88L626 514l-67.5 8.5-71.577 23.177L417.5 494.5 339 484l-31.5-79 22-33.5-32 33.5 38.5 89.5 77 6 65.554 47.887ZM596.5 729.5 581 760l6 42v-42l21-24.5-11.5-6ZM871 841l-60.5-75.5 10-5.5 24 37 28 3 17-18-12.5 24h-22.5l16.5 35Zm-36-151 36 7 10.5 35-4.5-48-50-16 8 22Zm334.5-10 30.5-18v-12.5l-37.5 25.5 7 65.5V680Zm276.5 28 33.5 38-8 78.5 16.5-84-33.5-37-8.5 4.5Zm251-115.5-34.5-48.5 7-6.5L1705 585v14h30.5l-30.5 11v71l-35.5 36.5L1697 681v-88.5ZM1504 507l22.5-20.5v-58L1519 483l-29.5 27 14.5-3ZM148.5 490 118 474l-18.5 36 23.5-26 25.5 26v-20Z" clip-rule="evenodd"/>
        <path class="crack-2" fill="#45254B" d="m321 554 150-32.5 31-2.653V430l-46-46 10.5-82.5v77l25.5 25 36-75.5v-26.5l8 26.5-34 79.5 9 22.5 7.169 87.463L582 512l96 4 9.397 2.04L707.5 440.5l60-27L781 356l-6.5 66.5 17 7.5 23-7.5-23 18-32-10.5-32.5 10.5 10 20-10 17v-17L714.5 449l-15 71.667 43 9.333 58.5-18 118-13 82 27.856 34-62.356 47.5-34.5-4.5-27 11.5 37.5-50 34.5-22.79 57.194 6.79 2.306 125-70L1168 499h49l18.5 17 94.5-38.5 74 17.293 49-44.293 16.5-41-11 55-38.77 33.97 2.27.53 73.5 46.5 110 30L1637 641l-37.5-55.5L1533 570l-53 28-58-37-81 24.5-79.5-5.5-93.5 18-48.2-6.211L1082.5 669l7 69.5 36 41.5-19 93 6-93-30-27H1056l-32.5 59.5 25.5-74h29l-7-53.5-36 15 36-26 36.97-83.736L1071 585.5l-85 6-88-26.5-47 85-131-40.5-68 16.5-70-34.5-14.163 4.015L564 653.5l-72 70 64.5-70v-54.772l-38 10.772-26.5 7-103-57-68 26-43.5-11H311l10-20.5ZM124 565l78.5 20.5-10 19.5-68.5-30.5-59 21-22.5 49 13.5-53 68-26.5ZM56 687l114-37 6 9-111 33.5L49 743l-35.5-8h29L56 687ZM244 506.5l9.5 47.5h16l-16-55-61-12.5 51.5 20ZM356.5 350.5l-51 53H298l46-53-23-57 35.5 57ZM568 161l-49.5 33.5-3 3L528 206l40-34h64.5L568 161ZM515.5 32 536 75l-8 22.5-17-56-23.5 9.5 28-19Z"/>
        <path class="crack-3" fill="#45254B" d="m970 328-45.5 65v-9l36.5-67h55.5l46-70-39 81H970ZM1243 384l-22 48.5h-16l30.5-48.5-5-67 12.5 67ZM1422 393l-45.5 10-6.5-19h45.5l37.5-67-8-48 24.5 42-47.5 82ZM1794 432.5l-59.5 42.5-4.5-10 46.5-43 23.5-51-6-54 20 54-14 51 30.5 28.5-36.5-18ZM1744.5 679l-42-28.5v-20l51 38.5v63.5l-9-53.5ZM1390 716.5l14-31.5-5-5.5-16 37 27 36.5-20-36.5ZM767.5 792l47-27 4.5 8.5-44.5 23.5-7 50.5V792ZM970 635.5l-24.5 18 3.5 9 21-18 26 18-26-27ZM990.5 780 949 765h-19l53 18-18.5 64.5 26-67.5ZM420.5 843l76.5-30.5 14 3.5-82.5 31.5-16 45 8-49.5ZM518.5 915l17.5-54-8 4-26 39 26 35-9.5-24ZM401.5 672.5l27-51-13 1.5-21 43-73.5 35 7 64v-57.5l73.5-35ZM289 644.5l67.5 5.5v-11.5h-72l-20.5 34 25-28Z"/>
        <g class="smokeContainer"></g>
      </svg>
    </div>
  </div>
  <h2 class="word" data-animation="hulk">Smash</h2>
  <p class="sr-only">Animation description: The green colored heading starts high above the purple colored background. As the word passes half way up the page it crashes quickly down, causing a large crack to appear.</p>
</section>

<section class="donut">
  <div class="background"></div>
  <h2 class="word"  data-animation="donuts">Donuts</h2>
  <p class="sr-only">Animation description: Each letter resembles a different flavor of donut. The letters start in the background and as the page scrolls up each donut animates into the foreground.</p>
</section>


              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Lilita+One&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Gluten:wght@500;700;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Dosis:wght@400;800&display=swap');

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

h1,
h2 {
  font-family: 'Lilita One', cursive;
  font-size: 15vmin;
  letter-spacing: .2rem;
  transform-style : preserve-3d;
  
  span {
    position: relative;
    z-index: 2;
  }
}

.sr-only {
  position:absolute;
  left:-10000px;
  top:auto;
  width:1px;
  height:1px;
  overflow:hidden;
}

.background {
  z-index: 0;
  position: absolute;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
}

section {
  perspective: 1500px;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-direction: column;
  will-change: transform;
  overflow: hidden;
}

.word {
  --layers: 5;
  --depth: 30;
  --increment: 0.1vmin;
  
  .safari & {
    --increment: 0.04vmin;
  }
  
  --color: darkred;
  --color-front: red;
  --color-back: var(--color);
  
  z-index: 1;
  transform-style : preserve-3d;
  position: relative;
  transform: rotatey(0deg);
  margin: 0;
  padding: 0;
  display: inline-block;
  
  .letter {
    --layer-space: calc(var(--depth) / var(--layers));
    --zStack: calc((var(--layer) * var(--layer-space)) * var(--increment));
    --xPositionOffset: 50%;
    --yPositionOffset: 50%;
    --zPositionOffset: calc(var(--increment) * ((var(--depth) * 0.5) * var(--centerOffset)));
    
    transform-style : preserve-3d;
    position: relative;
    color: var(--color);
    backface-visibility: hidden;
    transform: 
      translateX(calc((var(--x, 0) + var(--xOffset, 0)) * var(--increment))) 
      translateY(calc(var(--y, 0) * var(--increment))) 
      translateZ(calc(((var(--z, 0) - (var(--depth) * 0.5)) * var(--increment)) + var(--zStack)))
      rotateZ(calc(var(--rotateZ, 0) * 1deg))
      rotateY(calc(var(--rotateY, 0) * 1deg))
      rotateX(calc(var(--rotateX, 0) * 1deg));
    transform-origin: var(--xPositionOffset) var(--yPositionOffset) var(--zPositionOffset);
    
    &.front {
      color: var(--color-front);
      display: inline-block;
    }
    
    &.under{
      position: absolute;
      top: 0;
      left: calc(var(--xPos, 0) * 1px);
      pointer-events: none;
      user-select: none;
      display: inline-block;
      user-select: none;
      -webkit-user-select: none;
    }
    
    &.back {
      color: var(--color-back)
    }
  }
}

// Word styles

.boing {
  text-align: center;
  perspective: 500px;
  
  .background {
    background: #efefef;
    
    .sunburst {
      position: absolute;
      background: repeating-conic-gradient(#FFC2ED 0 15deg, #FFD6F3 15deg 30deg);
      left: 50%;
      top: 50%;
      width: 200vmax;
      height: 200vmax;
      opacity: 0;
      animation: spin 40s infinite linear;
      transform:  translate(-50%, -50%) rotate(0deg);
    }
  }

  .word {
    --color: #444;
    --color-front: #444;
    --depth: 2;
    --layers: 4;

    display: block;
  }
}

.intro {
  font-family: 'Dosis', sans-serif;
  font-weight: 400;
  color: #333;
  text-align: center;
  
  .background {
    // background-color: #F1EDEE;
  }
  
  h1 {
    font-weight: 400;
    font-size: max(5vmin, 30px);
    font-family: 'Dosis', sans-serif;
  }
  
  .word {
    --layers: 8;
    --depth: 0;
    --rotateAmount: 20deg;
    
    font-weight: 800;
    display: block;
    font-size: 15vmin;
    text-transform: uppercase;
    
    transform: rotateX(calc(var(--mouseX) * var(--rotateAmount))) rotateY(calc(var(--mouseY) * var(--rotateAmount)))
  }
  
  p {
    font-size: 1.5em;
  }
  
  .down-arrow { 
    margin-top: 3em;
  }
}

// Word styles

.hulk {
  overflow: unset;
  
  .background {
    width: 150%;
    background: 
      url('data:image/svg+xml,%3Csvg width="42" height="44" viewBox="0 0 42 44" xmlns="http://www.w3.org/2000/svg"%3E%3Cg id="Page-1" fill="none" fill-rule="evenodd"%3E%3Cg id="brick-wall" fill="%23893990" fill-opacity="0.4"%3E%3Cpath d="M0 0h42v44H0V0zm1 1h40v20H1V1zM0 23h20v20H0V23zm22 0h20v20H22V23z"/%3E%3C/g%3E%3C/g%3E%3C/svg%3E'),
      #99549F;
    background-size: 6em;
    background-position: center;
    
    .cracks {
      width: 100vw;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: visible;
      
      path {
        display: none;
      }
      
      &.smash-1 {
        .crack-1 {
          display: block;
        }
      }
      
      &.smash-2 {
        .crack-2 {
          display: block;
        }
      }
      
      &.smash-3 {
        .crack-3 {
          display: block;
        }
      } 
    }
    
    svg {
      width: 50em;
      padding-bottom: 10vmin;
    }
  }

  .word {
    --color: #124B28;
    --color-front: #2D8950;
    --color-back: #45254B;
    --depth: 100;
    --layers: 6;
    
    text-transform: uppercase;
    
    .back {
      opacity: 0.5;
    }
  }
  
}

.slide {
  .word {
    --color: #fff;
    --color-front: #eee;
    --depth: 1;
    --layers: 6;

    transform: rotatey(-20deg) rotatex(15deg);
    text-transform: uppercase;
  }
}


.oreo{
  perspective: 2000px;
  
  .background {
    background: radial-gradient(#66A3DB, #2E4A9B);
  }

  .word {
    --depth: 60;
    --layers: 7;
    --color: #CED3D1;
    --color-front: #362E2D;
    --color-back: #00000044;

    text-transform: uppercase;
    font-size: 25vmin;
    letter-spacing: 0em;
    
    [data-depth="6"] {
      --rotateY: 0 !important;
      --y: 1 !important;
      --z: 1 !important;
    }

    [data-depth="1"],
    [data-depth="4"],
    [data-depth="5"]{
      --color: var(--color-front);
    }
  } 
}

.donut {
  perspective: 600px;
  
  .background {
    background: 
      repeating-linear-gradient(
        -45deg,
        #606dbc00,
        #606dbc00 100px,
        #46529816 100px,
        #46529816 200px
      ),
      radial-gradient(#BBE9F0, #3FACB9),
  }
  
  .word {
    --layers: 7;
    --depth: 70;
    --color-front: #FFF4F7;
    --color-back: #3FACB9;
    --color: #F9AB59;
    
    font-size: 18vmin;
    font-family: 'Gluten', cursive;
    text-transform: uppercase;
    font-weight: 900;
    transform: rotatex(35deg);

    .back { opacity: 0.3;  }
    
    [data-depth="0"],
    [data-depth="5"] {
      font-weight: 500;
      --xOffset: 5;
    } 
    
    [data-depth="1"],
    [data-depth="4"] {
      font-weight: 700;
      --xOffset: 2;
    }
    
    [data-depth="2"],
    [data-depth="3"] {
      font-weight: 900;
    }
    
    [data-depth="2"],
    [data-depth="4"] {
      --color: #F8C58E;
    }
    
    [data-depth="3"] {
       --color: #FED89A;
    }
    
    [data-index="0"] {
      --rotateZ: 20;
    }

    [data-index="1"] {
      --y: 100;
    }
    
    [data-index="2"] {
      --y: 10;
      --rotateZ: -15;
      --x: -15;
    }
    
    [data-index="3"] {
      --y: 60;
    }  
    
    [data-index="5"] {
      --y: 60;
    }
    
    .front[data-index="0"] {
      background: 
        linear-gradient(25deg, transparent 0.2em, red 0.1em, red 0.23em, transparent 0.1em) 0.35em 0.09em / 0.1em 0.29em no-repeat,
        linear-gradient(-25deg, transparent 0.2em, purple 0.1em, purple 0.23em, transparent 0.1em) 0.1em 0.09em / 0.07em 0.29em no-repeat,
        linear-gradient(40deg, transparent 0.2em, orange 0.1em, orange 0.23em, transparent 0.1em) 0.1em 0.4em / 0.07em 0.29em no-repeat,
        linear-gradient(-10deg, transparent 0.2em, red 0.1em, red 0.23em, transparent 0.1em) 0.15em 0.5em / 0.06em 0.26em no-repeat,
        linear-gradient(20deg, transparent 0.2em, purple 0.1em, purple 0.22em, transparent 0.1em) 0.3em 0.5em / 0.08em 0.26em no-repeat,
        linear-gradient(-40deg, transparent 0.2em, orange 0.1em, orange 0.22em, transparent 0.1em) 0.44em 0.45em / 0.08em 0.26em no-repeat,
        linear-gradient(15deg, transparent 0.2em, red 0.1em, red 0.22em, transparent 0.1em) 0.54em 0.3em / 0.08em 0.26em no-repeat,
        white;
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      
      &::after {
        content: '';
        position: absolute;
        width: 0.12em;
        height: 0.13em;
        background-color: white;
        top: 67%;
        left: 30%;
        border-radius: 0 0 1em 1em;
        transform-origin: top center;
        transform: rotatex(-41deg) rotatey(5deg);
      }
    }
    
    .front[data-index="1"] {
      color: hotpink;
    }
    
    .front[data-index="2"] {
      color: chocolate;
    }
    
    .front[data-index="3"] {
      background: 
        linear-gradient(25deg, transparent 0.2em, brown 0.1em, brown 0.23em, transparent 0.1em) 0.1em 0.13em / 0.04em 0.29em no-repeat,
        linear-gradient(-25deg, transparent 0.2em, brown 0.1em, brown 0.23em, transparent 0.1em) 0.1em 0.09em / 0.04em 0.26em no-repeat,
        linear-gradient(40deg, transparent 0.2em, brown 0.1em, brown 0.23em, transparent 0.1em) 0.1em 0.4em / 0.04em 0.29em no-repeat,
        linear-gradient(-10deg, transparent 0.2em, brown 0.1em, brown 0.23em, transparent 0.1em) 0.15em 0.5em / 0.04em 0.26em no-repeat,
        linear-gradient(20deg, transparent 0.2em, brown 0.1em, brown 0.22em, transparent 0.1em) 0.3em 0.5em / 0.04em 0.26em no-repeat,
        linear-gradient(-40deg, transparent 0.2em, brown 0.1em, brown 0.22em, transparent 0.1em) 0.44em 0.45em / 0.04em 0.26em no-repeat,
        linear-gradient(15deg, transparent 0.2em, brown 0.1em, brown 0.22em, transparent 0.1em) 0.54em 0.3em / 0.04em 0.26em no-repeat,
        linear-gradient(-23deg, transparent 0.2em, brown 0.1em, brown 0.22em, transparent 0.1em) 0.54em 0.15em / 0.04em 0.26em no-repeat,
        linear-gradient(-23deg, transparent 0.2em, brown 0.1em, brown 0.22em, transparent 0.1em) 0.54em 0.45em / 0.04em 0.26em no-repeat,
        linear-gradient(-7deg, transparent 0.2em, brown 0.1em, brown 0.22em, transparent 0.1em) 0.42em 0.52em / 0.04em 0.26em no-repeat,
        pink;
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
    
    .front[data-index="4"] {
      background: 
        repeating-radial-gradient(
          white,
          white 0.1em,
          chocolate 0.101em,
          chocolate 0.125em,
        ),
        white;
      background-position:  9.45em 2.2em;
      background-size: 1.5em 1.5em;
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
    
    [data-index="2"] {
      &[data-depth="1"],
      &[data-depth="4"] {
        --xOffset: 6;
      }
      
      &.front,
      &[data-depth="5"] {
        --xOffset: 10;
      }
    }
    
    [data-index="3"] {
      &[data-depth="1"],
      &[data-depth="5"] {
        --xOffset: 6;
      }
      
      &.front,
      &[data-depth="5"] {
        --xOffset: 10;
      }
    }
    
    &.bite {
      [data-index="1"] {
        clip-path: path('M100 0H0v100h42.2a18.865 18.865 0 0 1-.642-4.895c0-8.755 5.972-16.116 14.065-18.23a18.935 18.935 0 0 1-.362-3.694c0-10.406 8.436-18.842 18.842-18.842 3.436 0 6.658.92 9.432 2.528C86.991 52.673 92.225 50 98.083 50c.647 0 1.287.033 1.917.096V0Z');
      }
    }
    
  }
}

@keyframes spin {
  100% { transform:  translate(-50%, -50%) rotate(360deg); }
}
              
            
!

JS

              
                console.clear()

class Word {
  constructor (element) {
    this.element = element;
    this.init()
  }
  
  init() {
    this.letters = [];
    this.layers = 1;
    
    this.wordString = this.element.innerText
    this.element.innerHTML = '';
    this.element.setAttribute('aria-label', this.wordString)
    
    const letterStrings = this.wordString.split('');
    const style = getComputedStyle(this.element);
    this.layers = Number(style.getPropertyValue('--layers'));
    
    this.letters = letterStrings.map((letter, i) => new Letter(letter, this.layers, this.element, i, letterStrings.length))
    
    const animation = this.element.dataset.animation;
    if(animation && animations[animation]) animations[animation](this)
  }
  
  reset() {
    this.init()
  }
  
  onResize() {
    this.element.style.setProperty("--width", this.element.clientWidth);
    this.element.style.setProperty("--height", this.element.clientHeight);
    this.letters.forEach(letter => letter.resize())
  }
}

class Letter {
  constructor(letterString, count, container, index, total) {
    this.container = container
    this.character = letterString;
    this.mainElement = null;
    this.position = { x: 0, y: 0 };
    this.elements = [];
    this.index = index;
    
    this.createLayers(count)
  }
  
  createLayers(count) {
    for(let i = 0; i < count; i++) {

      const layer = i;

      const span = document.createElement('span')
      span.setAttribute('aria-hidden', true)
      span.classList.add('letter')
      span.classList.add(i == 0 ? 'front' : 'under')
      if(i) span.setAttribute('contenteditable', false)
      if(i == count - 1) span.classList.add('back')
      span.innerHTML = this.character === ' ' ? '&nbsp;' : this.character;
      span.dataset['depth'] = layer;
      span.dataset['index'] = this.index;
      span.style.setProperty("--layer", count - layer);
      span.style.setProperty("--centerOffset", (layer - (count - 1) * 0.5 ) / ((count - 1) * 0.5) );
     
      this.elements.push(span)

      if(i === 0) {
        this.mainElement = span;
      }

      this.container.appendChild(span)
    }
  }
  
  resize() {
    const x = this.mainElement.offsetLeft
      
    this.elements.forEach(span => {
      span.style.setProperty("--xPos", x);
    })
  }
}

// Animations

const animations = {
  simple: (word) => {
    gsap.fromTo(word.element, {rotateY: -40}, {rotateY: 40, ease: 'power2.inOut', yoyo: true, repeat: -1, duration: 5})
  },
  intro: (word) => {
    const tl = gsap.timeline()
    
    word.letters.forEach((letter, i) => {
      letter.elements.forEach((layer, j) => {
        tl.fromTo(layer, {'--depth': 1}, {'--depth': 150, ease: 'back', duration: 0.5}, 0.1 * i)
      })
    })
    
    gsap.to('.down-arrow', {yPercent: 100, yoyo: true, repeat: -1, duration: 0.7})
    
    const introSection = document.querySelector('.intro');
    let mouseOver = false;
    let position = {x: 0.5,  y: 0.5};
    introSection.addEventListener('mouseover', () => {mouseOver = true})
    introSection.addEventListener('mouseout', () => {mouseOver = false})
    introSection.addEventListener('mousemove', (e) => {
      if(mouseOver) {
        const y = e.clientY / window.innerHeight
        position.x = e.clientX / window.innerWidth;
        position.y = e.clientY / window.innerHeight;
      }
    })
    
    const tick = () => {
      if(mouseOver) {
        let x = position.y * 2 - 1;
        gsap.set(introSection, {'--mouseX': x - x * 2, '--mouseY': position.x * 2 - 1})
      }
      window.requestAnimationFrame(tick)
    }
    tick();
  },
  hulk: (word) => {
    
    let smashes = 0;
    
    const cracks = document.querySelector('.cracks')
    const smokeContainer = document.querySelector('.smokeContainer')
    const smokeParticles = []
    
    const size = {
      width: 1831,
      height: 939
    }
    
    const resetSmash = () => {
      smashes = 0;
      cracks.classList.remove('smash-1', 'smash-2', 'smash-3')
    }
    
    ScrollTrigger.create({
      trigger: '.hulk',
      start: 'top bottom',
      end: 'bottom top',
      onToggle: self => {
        if(self.isActive) resetSmash();
      }
    });
    
    for(let i = 0; i < 20; i++) {
      const particle = document.createElementNS('http://www.w3.org/2000/svg', 'use');
      particle.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#smoke');
      smokeContainer.appendChild(particle)
      smokeParticles.push(particle);
      
      gsap.set(particle, {scale: 1, xPercent: 0, yPercent: 0, x: size.width * 0.15 + Math.random() * (size.width * 0.6), y: size.height * 0.5 - 25, opacity: 0})
    }
    
    const smokeAnimate = () => {
      
      smokeParticles.forEach((particle) => {
        
        gsap.set(particle, {scale: 1, xPercent: 0, yPercent: 0, x: size.width * 0.15 + Math.random() * (size.width * 0.6), y: size.height * 0.5 - 25, opacity: 0})
        gsap.to(particle, {scale: 1.5, rotate: 'random(-50, 50)' , xPercent: 'random(-100, 100)', yPercent:  'random(-50, 50)', keyframes: [{opacity: 1}, {opacity: 0}], duration: 2, ease: 'power4.out'})
      })
    }
    
    const shake = () => {
      gsap.to(word.element.parentNode, {keyframes: [{x: -75}, {x: 0}], ease: 'elastic', duration: 0.5})
    }
    
    const tl = gsap.timeline({
      scrollTrigger: {
        trigger: word.element,
        start: "top center",
        end: "top 25%",
        toggleActions: "restart none none reverse"
      },
      onComplete: () => {
        smashes++;
        if(smashes < 4){
          cracks.classList.add('smash-' + smashes);
        }
        smokeAnimate()
        shake()
      }
    })
    word.letters.forEach((letter, i) => {
      tl.from(letter.elements.slice(0, -1), {
          z: '+=400', 
          ease: 'back.in',
          duration: 0.2,
          
      }, 0)
    })
  },
  slide: (word) => {
    const tl = gsap.timeline({
      scrollTrigger: {
        
        trigger: word.element,
        start: "bottom 90%",
        end: "top 10%",
        toggleActions: "restart reverse restart reverse"
      },
      defaults : {
        ease: 'power4.out',
        duration: 1
      }
    });
    let count = 0;
    const colors = ['#EE6352', '#59CD90', '#3FA7D6', '#FAC05E']
    const tops = ['#F9CDC8', '#D0F0DF', '#CDE8F3', '#FCE8C5']
    word.letters.forEach((letter, i) => {
      letter.elements.forEach((layer, j) => {
        let isBottom = false;
        let color = colors[count % colors.length];
        if(j == 0) color = tops[count % colors.length]
        if(j == letter.elements.length - 1) {
          color = '#444';
          isBottom = true;
        }
        const delay = 0.05 * i;
        
        tl.to(layer, {       
          delay,
          color: color,
          duration: i == 0 ? 1 : 0.05
        }, 0)
        
        tl.to(layer, {
          '--depth': 50, 
          '--z': isBottom ? 40 : 60,         
          delay
        }, 0)
      })
      if(letter.character !== ' ') count++;
    })
  },
  spin: (word) => {
    gsap.to(word.element, {rotateY: 360, duration: 6, ease: 'none', repeat: -1})
    gsap.to(word.element, {rotateX: 360, duration: 7, ease: 'none', repeat: -1})
    gsap.to(word.element, {rotateZ: 360, duration: 8, ease: 'none', repeat: -1})
  },
  curve: (word) => {
    gsap.fromTo(word.element, {rotateY: 40, rotateZ: 20, rotateX: 20, xPercent: 25}, {rotateY: -40, rotateZ: -20, rotateX: 0, xPercent: -25, ease: 'power3.inOut', scrollTrigger: {
      trigger: word.element.parentNode,
      start: "top bottom",
      end: "bottom top",
      scrub: 0.3
    }})
  },
  donuts: (word) => {
    const rotateZ = [0, 0, -15, -20, 0, 0]
    const y = [0, 100, 10, 60, 0, 60]
    const x = [0, 0, -15, 10, 0, 0]
    
    const tl = gsap.timeline({scrollTrigger: {
            trigger: word.element,
            start: "top 80%",
            toggleActions: "restart none none reverse"
        }});
    
    tl.from(word.element, {rotateX: 60,  duration: 1.5, ease: 'back.inOut'})
    
    word.letters.forEach((letter, i) => {
       
      const rotateRand = Math.random() * 400 - 300
      const durationRand = Math.random() * 0.2
      
      tl.fromTo(letter.elements, { 
          '--x': 0, 
          '--y': -600,
          '--z': 0,
          
          '--rotateZ': -50 + -25 * (i+1),
      },{
        '--x': x[i],
        '--y': y[i],
        '--z': 0,
         '--rotateZ': rotateZ[i] ,
          delay: i * 0.05,
          ease: 'back.inOut',
          duration: 1.5 ,
          
      }, 0)
      
      
    })
  },
  boing: (word) => {
    const tl = gsap.timeline({
      scrollTrigger: {
        
        trigger: word.element,
        start: "50% 60%",
        toggleActions: "play reverse play reverse"
      },
      defaults : {
        ease: 'elastic',
        duration: 1.5
      }
    });
    
    tl.to('.sunburst', {opacity: 0.7, ease: 'power4.out'}, 0)
    
    let count = 0;
    const shades = [['#91A6FF', '#ADBCFF'],['#FF88DC', '#FFADE7'],['#6AB489', '#77BB93'],['#FF7073', '#FF8587'],['#C36BDB', '#CA7CDF'], ['#FAA275', '#FBAF89'] ]
    const tops =  ['#4769FF', '#FF47C8', '#4B956A', '#FF3336', '#AF3ACF', '#F76C26']
    const rotations = [
      {x: -3, y: -4},
      {x: 2, y: -2.5},
      {x: -1, y: -1},
      {x: 2, y: 2},
      {x: -4, y: 2.5},
      {x: 1, y: 2},
      {x: -2, y: 5},
    ]
    word.letters.forEach((letter, i) => {
      letter.elements.forEach((layer, j) => {
        let colors = shades[i % shades.length]
        let color = colors[j % colors.length];
        if(j == 0) color = tops[count % tops.length]
        const delay = 0.05 * i;
        
        tl.to(layer, {       
          delay,
          color: color,
          duration: i == 0 ? 1 : 0.05
        }, 0)
        
        let power = ((letter.elements.length - 1) - j)
        let direction = i - word.letters.length
        
        tl.to(layer, {
          '--depth': 150, 
          '--x': -2 * power,
          '--rotateY': rotations[i % rotations.length].y * power,
          '--rotateX': rotations[i % rotations.length].x * power,
          '--z': 40,         
          delay
        }, 0)
        
      })
      if(letter.character !== ' ') count++;
    })
  },
  oreo: (word) => {

    const tl = gsap.timeline({
      scrollTrigger: {
        trigger: word.element.parentNode,
        start: "top 60%",
        end: "top top",
        scrub: 0.3,
        toggleActions: "play reverse play reverse"
      },
      defaults : {
        ease: 'linear',
        duration: 1
      }
    });
    
    tl.fromTo(word.element, { 
      rotateX: 90, 
      rotateY: 90,
    }, {
      rotateX: 50, 
      rotateY: 0, 
      duration: 15, 
      ease: 'power2.inOut'
    }, 0)
    
    word.letters.forEach((letter, i) => {
      letter.elements.forEach((layer, j) => {
        tl.fromTo(layer, {       
         '--x': -100 * i + 30 * i
        }, {
         '--x': 0,
          duration: 1 * i,
        }, 6)
        
        tl.fromTo(layer, {
          '--y': -40 ,
          '--z': 60,
          '--rotateY': -70,
        },{  
          '--z': 0,
          '--y': 0,
          '--rotateY': 0,
          duration: 1.5,
          ease: 'bounce'
        }, 6 + 1 * i + 0.05)
 
      })
    })
  }
}

// Create words

const words = [...document.querySelectorAll('.word')].map(element => new Word(element))

// Resize

const onResize = () => {
  words.forEach(word => word.onResize())
}
setTimeout(() => onResize(), 1000)

// Adjust perspective on scroll

const sections = [...document.querySelectorAll('[data-animate-perspective]')];

sections.forEach(section => {
 gsap.fromTo(section, { perspectiveOrigin: "50% -50%" },
  {
    ease: "none",
    perspectiveOrigin: "50% 150%",
    scrollTrigger: {
      trigger: section,
      start: "top bottom",
      end: "bottom top",
      scrub: true
    },
  });
})

onResize()
window.addEventListener('resize', () => onResize())

// a little help with safari
if (navigator.vendor.startsWith('Apple')) document.documentElement.classList.add('safari');

              
            
!
999px

Console