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

              
                <link href="https://fonts.googleapis.com/css2?family=Fira+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Lexend:wght@100..900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Climate+Crisis&family=Fira+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Lexend:wght@100..900&display=swap" rel="stylesheet">


<div class="s-hero">
  <h1 class="s__title">
    100 Day Challenge<br/>
    by Suz Sirunyan<br/>
    Day 88/100
  </h1>
  
  <div class="s__catcher">
    Underneath It all
  </div>
  
  <div class="s__burger">
    <div class="s__burger__line"></div>
    <div class="s__burger__line"></div>
    <div class="s__burger__line"></div>
  </div>
</div><!-- .s-hero -->
  
<div class="s-scene">
  <div class="s__title">
    <div class="s__title__line">
      We Are All
    </div>
    <div class="s__title__line">
      A Little Bit
    </div>
  </div>
  
  <div class="s__word js-word">
    <div class="s__word__char">M</div>
    <div class="s__word__char">A</div>
    <div class="s__word__char">D</div>
  </div>
</div><!-- .s-scene -->

<div class="cursor js-cursor"></div>
  
<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" width="100" height="100" class="s-svg js-svg">
  <mask id="mask">
    <g class="js-wrapper" filter="url(#gooey)"></g>
  </mask>
  <filter id="gooey">
    <feGaussianBlur in="SourceGraphic" stdDeviation="25" />

    <feColorMatrix type="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 30 -7" result="goo" />
  </filter>
</svg>
              
            
!

CSS

              
                .s-hero {
  position: fixed;
  top: 0;
  left: 0;
  
  width: 100%;
  height: 100%;
  
  background: #f1f0f9;
  cursor: none;
  
  color: #0c0b0e;
  font-family: "Fira Sans", sans-serif;

  .s__title {
    position: absolute;
    top: 2vw;
    left: 2vw;

    margin: 0;
    padding: 0;

    font-size: 1.25vw;
  }

  .s__catcher {
    position: absolute;
    left: 0;
    bottom: 0;

    width: 100%;

    font-weight: 700;
    font-size: 13vw;
    letter-spacing: -0.025em;
    text-align: center;
    white-space: nowrap;
  }

  .s__burger {
    position: absolute;
    top: 2vw;
    right: 2vw;

    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: center;
    width: 56px;
    height: 48px;


    &__line {
      margin: 5px 0;
      width: 100%;
      height: 2px;
      background: #0c0b0e
    }
  }
}

.s-scene {
  position: fixed;
  top: 0;
  left: 0;
  
  width: 100%;
  height: 100%;
  
  background: #0c0b0e;
  mask: url(#mask);
  
  color: #f1f0f9;
  
  pointer-events: none;
  
  .s__title {
    position: absolute;
    top: 2vw;
    right: 2vw;
    left: 2vw;
    
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    
    font-weight: 700;
    font-size: 13vw;
    letter-spacing: -0.025em;
    line-height: 0.9;
    
    &__line {
      &:nth-child(2) {
        margin-left: auto;
      }
    }
  }
  
  .s__word {
    --max-scale: 3;
    
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    
    display: flex;
    justify-content: center;
    flex-direction: row;
    
    font-family: "Climate Crisis", sans-serif;
    font-size: 20vw;
    font-weight: 800;
    text-transform: uppercase;
    
    @keyframes char-scale {
      0% {
        scale: 1 0.1;
        // animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
      }
      50% {
        scale: 1 var(--max-scale);
      }
      100% {
        scale: 1 0.1;
      }
    }
    &__char {
      animation: char-scale 1.25s cubic-bezier(0.65, 0, 0.35, 1) infinite;
      transform-origin: 50% 86.5%;
      
      &:nth-child(1) {
        color: #fe6319;
        
        
      }
      
      &:nth-child(2) {
        color: #ff68a8;
        animation-delay: 0.25s;
      }
      
      &:nth-child(3) {
        color: #009800;
        animation-delay: 0.5s;
      }
    }
  }
}

.cursor {
  position: fixed; 
  top: -1.5vw;
  left: -1.5vw;
  z-index: 2;
  
  width: 3vw;
  height: 3vw;
  
  background: #88f901;
  border-radius: 50%;
  transform: translate3d(var(--x), var(--y), 0);
  
  pointer-events: none;
}

.s-svg {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 3;
  
  width: 100%;
  height: 100%;
  
  pointer-events: none;
}
              
            
!

JS

              
                // Selectors
const svg = document.querySelector('.js-svg')
const mask = document.querySelector('#mask')
const wrapper = document.querySelector('.js-wrapper')
const cursor = document.querySelector('.js-cursor')
const word = document.querySelector('.js-word')

const mouse = {
  x: 0,
  y: 0,
  smoothX: 0,
  smoothY: 0,
  diff: 0
}
const viewport = {
  width: window.innerWidth,
  height: window.innerHeight
}
const particles = []
let particleCnt = 0

// Mouse move
function onMouseMove (e) {
  mouse.vx += mouse.x - e.pageX
  mouse.vy += mouse.y - e.pageY
  
  mouse.x = e.pageX
  mouse.y = e.pageY
}
window.addEventListener('mousemove', onMouseMove)

// Resize
function onResize () {
  viewport.width = window.innerWidth
  viewport.height = window.innerHeight
  
  svg.style.width = viewport.width + 'px'
  svg.style.height = viewport.height + 'px'
  
  const wordHeight = word.clientHeight
  const maxScale = viewport.height / (word.clientHeight * 0.75)
  word.style.setProperty('--max-scale', maxScale)
}
window.addEventListener('resize', onResize)
onResize()

// Emitter
function emitParticle () {
  let x = 0
  let y = 0
  let size = 0
  
  if (mouse.diff > 0.01) {
    x = mouse.smoothX
    y = mouse.smoothY
    size = mouse.diff * 0.2
  }

  const particle = new Particle(x, y, size)
  particleCnt += 5

  particles.push(particle)
  wrapper.prepend(particle.el)
}

// Render
function render (time) {
  // Smooth mouse
  mouse.smoothX += (mouse.x - mouse.smoothX) * 0.1
  mouse.smoothY += (mouse.y - mouse.smoothY) * 0.1
  
  mouse.diff = Math.hypot(mouse.x - mouse.smoothX, mouse.y - mouse.smoothY)
  
  emitParticle()
  
  // Cursor
  cursor.style.setProperty('--x', mouse.smoothX + 'px')
  cursor.style.setProperty('--y', mouse.smoothY + 'px')
  
  // Render particles
  particles.forEach(particle => {
    particle.render(time)
  })
  
  // raf
  requestAnimationFrame(render)
}

window.addEventListener('load', render)

/**
 * Particle
 */
class Particle {
  // Constructor
  constructor (x, y, size) {
    this.size = size
    this.x = x
    this.y = y
    this.seed = Math.random() * 1000
    this.freq = (0.5 + Math.random() * 1) * 0.01
    this.amplitude = (1 - Math.random() * 2) * 0.5

    this.color = '#fff'

    this.el = document.createElementNS('http://www.w3.org/2000/svg', 'circle')
    this.el.setAttribute('cx', this.x)
    this.el.setAttribute('cy', this.y)
    this.el.setAttribute('r', this.size)
    this.el.setAttribute('fill', this.color)
    
    // Lifetime
    const tl = gsap.timeline()
    tl.to(
      this,
      {
        size: this.size * 2,
        ease: 'power1.inOut',
        duration: 2
      }
    )
    
    tl.to(
      this,
      {
        size: 0,
        ease: 'power4.in',
        duration: 4
      },
      3
    )
    
    tl.call(this.kill.bind(this))
  }
  
  // Kill
  kill () {
    const self = this

    particles.forEach((particle, index) => {
      if (particle === self) {
        particles.splice(index, 1)
      }
    })
 
    self.el.remove()
  }
  
  // Render
  render (time) {
    // this.x += Math.cos((time + this.seed) * this.freq) * this.amplitude + this.vx
    // this.y += Math.sin((time + this.seed) * this.freq) * this.amplitude + this.vy

    this.el.setAttribute('cy', this.y)
    this.el.setAttribute('cx', this.x)
    this.el.setAttribute('r', this.size)
  }
}
              
            
!
999px

Console