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

              
                <p class="animated-title" aria-label="In space no one can hear you scream."></p>

<button onclick="replay()" class="button-replay">
  Replay
</button>
              
            
!

CSS

              
                // Increase animation delay. The higher the number is, the slower the animation is
$speed: 10;

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');

.animated-title { 
  color: white;
  font-size: 48px;
  margin: 0;
  width: 100%;
  text-align: center;
  font-family: 'Share Tech Mono', monospace;
  animation: textGlitch 3s ease-in-out infinite alternate;
}

.animated-title {
  span {
    display: inline-block;
    min-width: 1rem;
  }
  
  .animate {
    @for $i from 1 through 100 {
      &:nth-child(3n+#{$i}){
        span {
          opacity: 0;
          transform: translateY(2px);
          animation: displayLetter .5s ease-in-out .5s forwards alternate;
          letter-spacing: 1px;

          @for $i from 1 through 100 {
            &:nth-child(3n+#{$i}){
              animation-delay: (random($speed) / 10) * 1s
            }
          }
        }
      }
    }
  }
}

.animated-word {
  opacity: 0;
}

@keyframes displayLetter {
	0% {
    transform: translateY(2px);
    color: white;
    opacity: 0;
	}
  10% {
    opacity: 1;
    color: limegreen;
  }
  20% {
    opacity: 0;
    color: white;
    transform: translateY(0px);
  }
  50% {
    opacity: 1;
    color: darkgreen;
    transform: translateY(1px);
  }
  60% {
    opacity: 1;
    color: white;
    transform: translateY(1px);
  }
	100% {
    transform: translateY(0);
    color: white;
    opacity: 1;
	}
}

@keyframes textGlitch {
  0% {
    opacity: 1;
  }
  94% {
    opacity: 1;
    transform: translateX(0px);
  }
	95% {
    opacity: 0.1;
  }
  96% {
    opacity: 1;
    transform: translateX(1px);
  }
  97% {
    opacity: 0.1;
  }
  100% {
    opacity: 1;
    transform: translateX(0px);
  }
}

// Demo Only Styling
body {
  background-color: black;
  margin: 0;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}
.button-replay {
  position: absolute;
  top: 10px;
  left: 10px;
  border: solid 2px white;
  outline: none;
  padding: 10px 20px;
  text-transform: uppercase;
  font-weight: bold;
  cursor: pointer;
  background: black;
  color: white;
}
              
            
!

JS

              
                let animationContainer = document.querySelector('.animated-title');
let textData = animationContainer.getAttribute('aria-label');

function splitWords() {
  let splitedText = textData.split(' ');
  
  splitedText.join('& &').split('&').forEach(function(e){
    let span = document.createElement('span');
    span.classList.add('animated-word');
    span.setAttribute('data-text', e); 
    animationContainer.appendChild(span);
  });
  splitLetters();
}
splitWords()


function splitLetters() {
  let animatedWords = document.querySelectorAll('.animated-word');
  animatedWords.forEach(function(e, i){
    e.getAttribute('data-text').split('').forEach(function(f, j) {
      f = f == ' ' ? '&#32;' : f;
      let span = document.createElement('span');
      span.classList.add('animated-element');
      span.setAttribute('aria-hidden', 'true'); 
      span.innerHTML = f;
      e.appendChild(span);
    });
    animate(e, i);
  })
}

function animate(e, i) {
  let wordCount = e.getAttribute('data-text').length;
  e.style.opacity = 1;
  e.classList.add('animate');
}

// Replay Button - For Demo purpose only
function replay() {
  let animatedWords = document.querySelectorAll('.animated-word');
  animatedWords.forEach(function(e, i){
    e.classList.remove('animate');
    e.style.opacity = 0;
    setTimeout(() => {
      animate(e, i);
    }, 500);
  })
}
              
            
!
999px

Console