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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <button id="Btn" class="btn">Random Text</button>
<div class="item">
  <div class="title">FadeIn</div>
  <div class="content">
    <div class="text-wrapper" id="Effect1"></div>
  </div>
</div>
<div class="item">
  <div class="title">FadeUpInOut</div>
  <div class="content">
    <div class="text-wrapper" id="Effect2"></div>
  </div>
</div>
<div class="item">
  <div class="title">Typewriter</div>
  <div class="content">
    <div class="text-wrapper border-blink" id="Effect3"></div>
  </div>
</div>
              
            
!

CSS

              
                .item {
  margin: 30px 0 60px;
  display: flex;
  align-items: center;
}
.item .title {
  font-size: 14px;
  color: #898989;
  width: 100px;
  text-align: right;
  margin-right: 20px;
}
.text-wrapper {
  font-family: Consolas, Monaco, Lucida Console, Liberation Mono,
    DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace;
  display: inline-block;
  overflow: hidden;
  letter-spacing: 1px;
  font-size: 24px;
  color: #262626;
  height: 32px;
  line-height: 32px;
}
.border-blink {
  border-right: 1px solid #262626;
  animation: borderBlink 0.8s infinite;
}
@keyframes borderBlink {
  0% {
    border-color: #262626;
  }
  50% {
    border-color: #262626;
  }
  51% {
    border-color: transparent;
  }
  100% {
    border-color: transparent;
  }
}
.btn {
  display: inline-flex;
  outline: none;
  border: none;
  position: relative;
  align-items: center;
  user-select: none;
  vertical-align: middle;
  -moz-appearance: none;
  justify-content: center;
  text-decoration: none;
  background-color: transparent;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  padding: 6px 16px;
  font-size: 0.875rem;
  min-width: 64px;
  box-sizing: border-box;
  transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
    box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
    border 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
  font-family: "Roboto", "Helvetica", "Arial", sans-serif;
  font-weight: 500;
  line-height: 1.75;
  border-radius: 4px;
  letter-spacing: 0.02857em;
  text-transform: uppercase;
  color: #fff;
  background-color: #1976d2;
}
              
            
!

JS

              
                const randomText = () => {
  const length = ~~(Math.random() * 6) + 6;
  const text = Math.random().toString(16).slice(2, length).toUpperCase();
  return text;
};
const changeRandomText = () => {
  const text = randomText();
  animateEffect1(text);
  animateEffect2(text);
  animateEffect3(text);
};
changeRandomText();
Btn.addEventListener("click", changeRandomText);

async function animateEffect1(text) {
  const target = document.querySelector("#Effect1");
  target.innerText = text;
  target.animate({ opacity: [0, 1] }, 600);
}

async function animateEffect2(text) {
  const target = document.querySelector("#Effect2");
  await target.animate(
    {
      opacity: [1, 0],
      transform: ["translateY(0)", "translateY(-20px)"],
    },
    300
  ).finished;
  target.innerText = text;
  target.animate(
    {
      opacity: [0, 1],
      transform: ["translateY(20px)", "translateY(0)"],
    },
    300
  );
}

async function animateEffect3(text) {
  const target = document.querySelector("#Effect3");
  const beforeWidth = target.offsetWidth;
  const textBeforeLength = target.innerText.length;
  if (textBeforeLength > 0) {
    await target.animate(
      [
        {
          width: `${beforeWidth}px`,
        },
        {
          width: 0,
        },
      ],
      {
        duration: textBeforeLength * 100,
        easing: `steps(${textBeforeLength})`,
      }
    ).finished;
  }
  target.innerText = text;
  const afterWidth = target.offsetWidth;
  const textAfterLength = target.innerText.length;
  target.animate(
    [
      {
        width: 0,
      },
      {
        width: `${afterWidth}px`,
      },
    ],
    {
      duration: textAfterLength * 100,
      easing: `steps(${textAfterLength})`,
    }
  );
}
              
            
!
999px

Console