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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <link href="https://fonts.googleapis.com/css2?family=Graduate&display=swap" rel="stylesheet" />

<button id="button" class="glitch-button" aria-label="uplink">
  <svg xmlns="http://www.w3.org/2000/svg" width="900" height="240" viewBox="0 0 900 240" preserveAspecRatio="xmidYMid slice" xml:space="preserve">
    <defs>
      <filter id="dm-filter--hover" color-interpolation-filters="sRGB" preserveAspectRatio="none">
        <feFlood x="0" y="0" width="120%" height="100%" flood-color="rgb(128, 0, 128)" result="FEIMG-NO-TRANSFORM" />
        <feFlood x="0" y="0" width="120%" height="6px" flood-color="rgb(256, 0, 128)" result="FEIMG-XMAX">
          <animate attributeName="height" values="6px; 1px; 6px" dur="4s" repeatCount="indefinite" begin="0" />
          <animate attributeName="y" values="80px; 160px; 120px; 160px; 90px; 140px; 80px" dur="10s" repeatCount="indefinite" begin="0" />
        </feFlood>
        <feFlood x="0" y="0" width="120%" height="6px" flood-color="rgb(0, 0, 128)" result="FEIMG-XMIN">
          <animate attributeName="height" values="6px; 12px; 4px" dur="6s" repeatCount="indefinite" begin="0" />
          <animate attributeName="y" values="80px; 100px; 160px; 110px; 80px; 140px; 90px; 100px; 80px; 150px; 80px" dur="20s" repeatCount="indefinite" begin="0" />
        </feFlood>
        <feMerge result="MERGE">
          <feMergeNode in="FEIMG-NO-TRANSFORM" />
          <feMergeNode in="FEIMG-XMAX" />
          <feMergeNode in="FEIMG-XMIN" />
        </feMerge>
        <feDropShadow in="SourceGraphic" dx="0" dy="0" stdDeviation="00" flood-color="lime" result="SHADOW_LIME">
          <animate class="anim" calcMode="discrete" attributeName="dx" values="0; 0; 0; 0; 2; 0; 5; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; -3; 0; 0; -2; 0; 0; 0; 0; 0; 2; 0; 0; 4; 0; -3; 0; -4; 0; 0; 2; 0; 0; 5; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0" dur="7s" repeatCount="indefinite" begin="0" fill="freeze" />
          <animate class="anim" calcMode="discrete" attributeName="dy" values="0; 0; -1; 0; 0; 0; 0; 0; 3; 0; 0; 0; 0; 0; 5; 0; 0; 0; 0; 0; 2; 0; 0; -4; -3; 0; 0; 0; 2; -1; 3; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0" dur="7.5s" repeatCount="indefinite" begin="0" fill="freeze" />
        </feDropShadow>
        <feDropShadow in="SourceGraphic" dx="0" dy="0" stdDeviation="00" flood-color="red" result="SHADOW_FUCHSIA">
          <animate class="anim" calcMode="discrete" attributeName="dx" values="0; 0; 0; 0; 0; 0; .2; 0; 0; 0; -1; 0; 0; 0; 0; 0; 0; 4; 0; 0; 0; 0; 0; 0; 3; 0; 0; 0; 0; -3; 0; 0; 0; 2; 0; 1; 4; 0; 0; 0; 0; 0; 0; 5; 0; 0; -3; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0" dur="8s" repeatCount="indefinite" begin="0" fill="freeze" />
          <animate class="anim" calcMode="discrete" attributeName="dy" values="0; 0; 2; 0; 0; 0; 0; 0; 0; 0; -2; 0; 0; 0; -4; 0; 0; 0; 0; -3; 0; 0; 0; 5; 3; 0; 0; 0; 0; 0; 0; 0; -2; 0; 0; 0; 4; 0; 0; 0; 0; 0; 0; 0; 0; 0; -1; 0; 0; 0; 0; 0; 0; 0; 0; 0" dur="7.7s" repeatCount="indefinite" begin="0" fill="freeze" />
        </feDropShadow>
        <feBlend in="SHADOW_LIME" in2="SHADOW_FUCHSIA" result="BLEND_SHADOW" mode="screen" />

        <feDisplacementMap in="BLEND_SHADOW" in2="MERGE" scale="10" xChannelSelector="R" yChannelSelector="B">
          <animate attributeName="scale" values="-10; 5; 0; 10; 3; 8; -2; -8; 4; -5; 10; 6" dur="10s" repeatCount="indefinite" begin="0" />
        </feDisplacementMap>
      </filter>
    </defs>
    <svg class="filter" xmlns="http://www.w3.org/2000/svg" width="600" height="400" viewBox="0 0 600 400" preserveAspecRatio="none">
      <defs>
        <filter id="dm-filter--active" color-interpolation-filters="sRGB" preserveAspectRatio="none">
          <feImage id="feimage-glitchmask-r" preserveAspectRatio="none" result="FEIMG-GLITCH-R" width="150%" height="100%" x="0" y="0">
            <animate class="glitch-anim" id="an" attributeName="width" values="100%; 200%; 100%" dur="0.3s" repeatCount="1" begin="click" />
            <animate class="glitch-anim" attributeName="height" values="100%; 200%; 100%" dur="0.2s" repeatCount="1" begin="click" fill="freeze" />
            <animate class="glitch-anim" attributeName="y" values="0; 50; 0" dur="0.25s" repeatCount="1" begin="click" />
          </feImage>

          <feImage id="feimage-glitchmask-b" preserveAspectRatio="none" result="FEIMG-GLITCH-B" width="150%" height="100%" x="0" y="0">
            <animate class="glitch-anim" attributeName="width" values="300%; 100%; 300%" dur="0.25s" repeatCount="1" begin="click" fill="freeze" />
            <animate class="glitch-anim" attributeName="height" values="80%; 100%; 80%" dur="0.3s" repeatCount="1" begin="click" fill="freeze" />
            <animate class="glitch-anim" attributeName="y" values="0; 10; 0" dur="0.2s" repeatCount="1" begin="click" />
          </feImage>

          <feBlend in="FEIMG-GLITCH-R" in2="FEIMG-GLITCH-B" result="BLEND_DMMAP" mode="screen" />

          <feDropShadow in="SourceGraphic" dx="0" dy="0" stdDeviation="00" flood-color="lime" result="SHADOW_LIME">
            <animate class="glitch-anim" calcMode="discrete" attributeName="dx" values="6; 11; 5; 0; 4; 0; -3; -7; 12; -2; -8; 0; 0; 17; 0; 6; 14; 6; -13; 0; -7; 0; 0; 8; 11; 4; 15; -7" dur="0.3s" repeatCount="1" begin="click" />
            <animate class="glitch-anim" calcMode="discrete" attributeName="dy" values="5; 0; -4; -9; 0; 11; 8; 0; 10; -8; 15; -12; 12; -6; 0; -8; -4; 6; 9; 16; 0; 4; -4; 5; 0; -10; 0" dur="0.4s" repeatCount="1" begin="click" />
          </feDropShadow>

          <feDropShadow in="SourceGraphic" dx="0" dy="0" stdDeviation="00" flood-color="red" result="SHADOW_RED">
            <animate class="glitch-anim" calcMode="discrete" attributeName="dx" values="0; 10; 14; -13; 0; -9; -13; 0; 16; 12; 10; -10; 8;  5; -6; 13; 0; 9; 11; 0; 14; 0; 0; -8; 3" dur="0.3s" repeatCount="1" begin="click" />
            <animate class="glitch-anim" calcMode="discrete" attributeName="dy" values="0; 7; 10; 3; -13; -8; -6; -8; 0; -12; 0; 0; 0; 14; 9; 0; 15; 17; 0; -6; 0; -9; 8; 14; -6; 0" dur="0.3s" repeatCount="1" begin="click" />
          </feDropShadow>

          <feBlend in="SHADOW_LIME" in2="SHADOW_RED" result="BLEND_SHADOW" mode="screen" />

          <feDisplacementMap in="BLEND_SHADOW" in2="BLEND_DMMAP" scale="0" xChannelSelector="R" yChannelSelector="B">
            <animate class="glitch-anim" attributeName="scale" values="0; 300; 0" dur="0.3s" repeatCount="1" begin="click" />
          </feDisplacementMap>
        </filter>
      </defs>
    </svg>
    <g id="filtered">
      <rect width="100%" height="100%" fill="transparent" />
      <text class="glitch-button__text" y="50%" x="50%" text-anchor="middle">
        <tspan dx="1" dy="31">[ T&#x200A;ickl&#160;&#160;&#160;&#160;&#160;&#160;&#160;Beam ]</tspan>
      </text>
      <text class="glitch-button__text" y="50%" x="50%" text-anchor="middle">
        <tspan dx="33" dy="31">[ By&#x200A;te&#160;&#160;&#160;&#160;&#160;&#160;&#160;Cranc ]</tspan>
      </text>
      <circle cx="50%" cy="50%" r="50px" fill="white" style="display: none;" />
      <image class="glitch-button__img" href="https://assets.codepen.io/100347/fedm_bot-1.svg" x="50%" y="50%" height="140" width="140" transform="translate(-70, -70)" />
      <image class="glitch-button__img" href="https://assets.codepen.io/100347/fedm_bot-2.svg" x="50%" y="50%" height="140" width="140" transform="translate(-70, -70)" />
      <g transform="translate(-90, -90)">
        <svg x="50%" y="50%" width="180" height="180" viewBox="-90 -90 180 180" style="overflow: visible;">
          <path class="spin1" id="arc1" d="" />
          <path class="spin2" id="arc2" d="" /> <!-- -->
          <path class="spin3" id="arc3" d="" />
        </svg>
      </g>
    </g>
  </svg>
</button>
              
            
!

CSS

              
                @use postcss-preset-env;

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
}

p {
    margin-bottom: 1em;
}

.filter {
    position: absolute;
    top: 0;
    left: -1;
    width: 1px;
    height: 1px;
    visibility: hidden;
}

body {
    margin: 0;
    padding: 1.25em;
    height: 100%;
    color: white;
    font: 0.85em -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    min-width: 320px;
    display: flex;
    align-items: center;
    text-align: center;
    background-color: #2e2d42;
    background-size: auto, contain, 100% 100%;

    @nest .jpg & {
        background-image: radial-gradient(circle, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.9) 80%),
        repeating-radial-gradient(circle, transparent, transparent 2px, #2a3d37 2px, #2a3d37 4px),
        url('https://assets.codepen.io/100347/fedm_metal.jpg');
    }

    @nest .webp & {
        background-image: radial-gradient(circle, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.9) 80%),
        repeating-radial-gradient(circle, transparent, transparent 2px, #2a3d37 2px, #2a3d37 4px),
        url('https://assets.codepen.io/100347/fedm_metal.webp');
    }
}

.glitch-button {
    display: block;
    border: none;
    background: transparent;
    position: relative;
    margin: 0 auto;
    flex: 0 0 auto;
    cursor: crosshair;

    &:hover {
        outline: none;
    }
}

@media screen and (prefers-reduced-motion: no-preference) {
    .glitch-button__filtered {
        &:active,
        &:hover,
        &:focus {
            filter: url('#dm-filter--hover');
        }

        @nest .glitch-button--morphing & {
            filter: url('#dm-filter--active');
        }
    }
}

.glitch-button__text {
    fill: white;
    font: 80px/0.75 'Graduate', sans-serif;
    text-transform: uppercase;
}

.glitch-button__text,
.glitch-button__img {
    @nest .glitch-button--inactive &:nth-of-type(1) {
        pointer-events: auto;
        animation: swapTextIn 0.15s 1 forwards;
    }

    @nest .glitch-button--active &:nth-of-type(1) {
        pointer-events: none;
        animation: swapTextOut 0.15s 1 forwards;
    }

    &:nth-of-type(2) {
        visibility: hidden;
        pointer-events: none;
    }

    @nest .glitch-button--inactive &:nth-of-type(2) {
        pointer-events: none;
        animation: swapTextOut 0.15s 1 forwards;
    }

    @nest .glitch-button--active &:nth-of-type(2) {
        pointer-events: auto;
        animation: swapTextIn 0.15s 1 forwards;
    }
}

.spin1,
.spin2,
.spin3 {
    fill: none;
    stroke-width: 6px;
    stroke: white;
    opacity: 1;
}

.spin2 {
    stroke-width: 3px;
}

.spin3 {
    stroke-width: 3px;
}

@keyframes swapTextOut {
    0% {
        visibility: visible;
    }

    100%,
    50% {
        visibility: hidden;
    }
}

@keyframes swapTextIn {
    0%,
    50% {
        visibility: hidden;
    }

    100% {
        visibility: visible;
    }
}

              
            
!

JS

              
                webpSupported();

new Spinner("#arc1", 88, 10, 50, 4000, -5000);
new Spinner("#arc2", 83.5, 90, 170, -6000, 10000);
new Spinner("#arc3", 92.5, 70, 260, 4500, 9000);

const button = document.getElementById("button");

async function fetchImage(imgURL, feImgID) {
  const imageFetched = new Promise((resolve) => {
    fetch(imgURL, {
      method: "GET",
      headers: new Headers(),
      mode: "cors",
      cache: "default"
    })
      .then((response) => {
        return response.text();
      })
      .then((svgText) => {
        const feImg = document.getElementById(feImgID);
        const uri = encodeURIComponent(svgText);

        if (feImg) {
          feImg.setAttribute("href", `data:image/svg+xml;charset=utf-8,${uri}`);

          resolve();
        }

        resolve(false);
      });
  });

  return await imageFetched;
}

Promise.all([
  fetchImage(
    "https://assets.codepen.io/100347/fedm_glitch-blue.svg",
    "feimage-glitchmask-b"
  ),
  fetchImage(
    "https://assets.codepen.io/100347/fedm_glitch-red.svg",
    "feimage-glitchmask-r"
  )
]).then(() => {
  requestAnimationFrame(() => {
    document
      .getElementById("filtered")
      .classList.add("glitch-button__filtered");
  });
});

const animations = document.querySelectorAll(".glitch-anim");
let timeout;
const animate = (option) => {
  for (let animation of animations) {
    animation[`${option}Element`]();
  }
};

const startAnim = () => {
  button.removeEventListener("click", startAnim);
  button.addEventListener("click", revertAnim);
  button.classList.remove("glitch-button--inactive");
  button.classList.add("glitch-button--active", "glitch-button--morphing");

  setTimeout(() => {
    button.classList.remove("glitch-button--morphing");
  }, 300);

  animate("begin");
  timeout = setTimeout(revertAnim, 8000);
};

const revertAnim = () => {
  clearTimeout(timeout);
  button.removeEventListener("click", revertAnim);
  button.addEventListener("click", startAnim);
  button.classList.remove("glitch-button--active");
  button.classList.add("glitch-button--inactive", "glitch-button--morphing");

  setTimeout(() => {
    button.classList.remove("glitch-button--morphing");
  }, 300);

  animate("begin");
};

button.addEventListener("click", startAnim);

              
            
!
999px

Console