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="wrapper">
  <div id="skywalker">
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 861 1000">
      <defs>
        <mask id="mask--molten-cracks">
          <image id="cracks--molten-mask" x="-315" y="-315" width="630" height="630" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/106403/rise-of-skywalker--cracks--molten-mask.png" transform="translate(465 340)"/>
        </mask>
        
        <mask id="mask--cracks">
          <image id="cracks--mask" width="512" height="560" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/106403/rise-of-skywalker--dark--mask.gif" transform="translate(208 32)"/>
        </mask>
        
        <mask id="mask--sith-lightsaber-turbulence">
          <rect width="100%" height="100%" fill="black"/>
          <image width="124" height="175" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/106403/lightsaber--turbulence--mask.jpg" transform="translate(435 763)"/>
        </mask>
        
        <filter id="filter--turbulence" filterUnits="objectBoundingBox" x="0" y="0" width="100%" height="100%">
          <feTurbulence id="turbulence" type="fractalNoise" numOctaves="4" seed="20"></feTurbulence>
          <feDisplacementMap xChannelSelector="R" yChannelSelector="G" scale="5" in="SourceGraphic"></feDisplacementMap>
        </filter>
      </defs>

      <image id="dark--no-cracks" width="861" height="1000" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/106403/rise-of-skywalker--dark.jpg"/>

      <g mask="url(#mask--molten-cracks)">
        <g mask="url(#mask--cracks)">
          <image id="cracks--dark" width="504" height="550" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/106403/rise-of-skywalker--dark--cracks.jpg" transform="translate(213 39)"/>
        </g>
      </g>

      <g class="bright">
        <image id="bright--no-cracks" width="861" height="1000" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/106403/rise-of-skywalker--bright.jpg"/>

        <g mask="url(#mask--molten-cracks)">
          <g mask="url(#mask--cracks)">
            <image id="cracks--bright" width="504" height="550" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/106403/rise-of-skywalker--bright--cracks.jpg" transform="translate(213 39)"/>
          </g>
        </g>
      </g>
      
      <g>
        <image id="lightsaber-glow--jedi--highlights" width="345" height="277" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/106403/rise-of-skywalker--lightsaber-highlights.jpg" transform="translate(245 239)"/>

        <image id="lightsaber-glow--jedi" width="425" height="181" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/106403/lightsaber-glow--jedi.gif" transform="translate(113 126)"/>
      </g>
      
      <g>
        <image id="lightsaber-glow--sith--highlights" width="154" height="232" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/106403/rise-of-skywalker--lightsaber-glow--sith--highlights.jpg" transform="translate(430 731)"/>
        
        <image id="lightsaber-glow--sith" width="124" height="175" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/106403/lightsaber-glow--sith.gif" transform="translate(435 763)"/>
      </g>
      
      <!-- mask & filter combo doesn't work in SVG on single element. Seems to work better with filter in CSS -->
      <g mask="url(#mask--sith-lightsaber-turbulence)">
        <image id="lightsaber-glow--sith--turbulence" width="154" height="232" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/106403/rise-of-skywalker--lightsaber-glow--sith--highlights.jpg" transform="translate(430 731)"/>
      </g>
    </svg>

    <div id="lightspeed-mask">
      <div id="space"></div>
    </div>

    <div id="embers">
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/106403/rise-of-skywalker--sparks.webp" width="100%" height="100%" alt="">
    </div>
  </div>
</div>
              
            
!

CSS

              
                body {
  background-color: black;
  position: relative;
  --innerVH: 100vh;
  height: var(--innerVH);
}

.wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: grid;
  place-items: stretch center;
}

#skywalker {
  position: relative;
  height: 100%;
  overflow: hidden;
}

svg {
  display: block;
  height: 100%;
}

image {
  image-rendering: crisp-edges;
}

#bright--no-cracks,
.bright {
  animation: darkside 20s infinite alternate;
}



#lightsaber-glow--jedi--highlights,
#lightsaber-glow--jedi {
  animation: lightside 20s infinite alternate;
}

#lightsaber-glow--jedi--highlights {
  mix-blend-mode: lighten;
}

#lightsaber-glow--jedi {
  mix-blend-mode: screen;
}



#lightsaber-glow--sith {
  mix-blend-mode: screen;
}

#lightsaber-glow--sith--highlights {
  mix-blend-mode: lighten;
}

#lightsaber-glow--sith,
#lightsaber-glow--sith--highlights {
  animation: darkside 1s infinite alternate;
}

#lightsaber-glow--sith--turbulence {
  filter: url(#filter--turbulence);
  mix-blend-mode: lighten;
}

@keyframes lightside {
  0% { opacity: 0.3 }
  10% { opacity: 0.6 }
  20% { opacity: 0.4 }
  30% { opacity: 1 }
  40% { opacity: 0.3 }
  50% { opacity: 0.6 }
  60% { opacity: 0.4 }
  70% { opacity: 0.6 }
  80% { opacity: 1 }
  90% { opacity: 0.1 }
  100% { opacity: 0.3 }
}

@keyframes darkside {
  0% { opacity: .3 }
  5% { opacity: .8 }
  15% { opacity: .4 }
  20% { opacity: 1 }
  25% { opacity: .3 }
  35% { opacity: .8 }
  45% { opacity: .2 }
  50% { opacity: 1 }
  55% { opacity: 0.3 }
  60% { opacity: 0.6 }
  65% { opacity: 0.4 }
  70% { opacity: 0.2 }
  80% { opacity: 0.6 }
  85% { opacity: 0.8 }
  90% { opacity: 0.4 }
  95% { opacity: 0.6 }
  100% { opacity: 0.3 }
}




#lightspeed-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  mask-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/106403/rise-of-skywalker--stars--alpha-mask.png);
  mask-size: 100% 100%;
  mix-blend-mode: screen;
  
  display: grid;
  
  &:after {
    display: block;
    content: '';
    grid-area: 1 / 1;
    background-image: linear-gradient(to right, #008aff 30%, #e10019);
    mix-blend-mode: overlay;
  }
}

#space {
  background-color: black;
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  
  overflow: hidden;
  
  display: grid;
  place-items: center center;
  
  --perspective: 100px;
  perspective: var(--perspective);
  transform-style: preserve-3d;
}

#space time {
  grid-area: 1 / 1;
  transform-origin: 50% 0%;
  background-color: white;
  box-shadow: 0 0 .5rem white, 0 0 1rem white, 0 0 1rem white;
  
  @supports (-moz-transition: all) {
    // Firefox can't hang...
    box-shadow: 0 0 .5rem white;
  }
}




#embers {
  position: absolute;
  top: 80%;
  left: 50%;
  height: 20%;
  width: 40%;
  mask-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/106403/rise-of-skywalker--sparks--alpha-mask.png);
  mask-size: 100% 100%;
  mix-blend-mode: screen;

  img {
    transform: rotate(180deg);
  }
}
              
            
!

JS

              
                document.body.style.setProperty('--innerVH', `${window.innerHeight || window.visualViewport.height}px`);



const space = document.getElementById("space"),
      spaceWidth = space.scrollWidth,
      spaceHeight = space.scrollHeight,
      perspective = 100;

space.style.setProperty(`--perspective`, `${perspective}px`);

function makeStar() {
  const star = document.createElement(`time`),
        starWidth = gsap.utils.random(1, 2, 1),
        starHeight = starWidth * gsap.utils.random(20, 40, 1),
        randomRotation = gsap.utils.random(-120, 120, 1),
        scaleModifier = Math.random(),
        visibleRangeMaximum = (spaceWidth - spaceHeight > 0 ? spaceWidth : spaceHeight) / 2;

  gsap.set(star, {
    width: `${starWidth}px`,
    height: `${starHeight}px`,
    transform: `
      translateY(${starHeight / 2}px)
      rotate(${randomRotation}deg)
      rotateX(90deg)
      translateZ(0px)
      scaleX(${scaleModifier})
    `,
  });
  
  gsap.to(star, {
    duration: "random(5, 20)",
    transform: `
      translateY(${starHeight / 2}px)
      rotate(${randomRotation}deg)
      rotateX(90deg)
      translateZ(${perspective + visibleRangeMaximum}px)
      scaleX(${scaleModifier})
    `,
    repeat: -1,
    ease: `none`,
  }).progress(Math.random());
  
  space.appendChild(star);
}

for (let i = 0; i < 200; i++) {
   makeStar();
}



const moltenCracksMask = document.querySelector(`#cracks--molten-mask`);

gsap.to(moltenCracksMask, {
  duration: 20,
  repeat: -1,
  ease: `none`,
  attr: {
    transform: `translate(465 340)  rotate(360 0 0) `
  },
  force3D: true,
})



const elTurbulence = document.querySelector(`#turbulence`);

gsap.to(elTurbulence, {
  duration: 4,
  repeat: -1,
  ease: `none`,
  onUpdate: function() {
    const baseFrequencyX = this.progress() * .004 + .02,
          baseFrequencyY = this.progress() * .04 + .01;
    
    elTurbulence.setAttribute(`baseFrequency`, `${baseFrequencyX} ${baseFrequencyY}`);
  }
})
              
            
!
999px

Console