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=Josefin+Sans:wght@700&display=swap" rel="stylesheet" />
<p>
  Simple 'Glitch' effect, created by applying a SMIL animation to an feFlood SVG filter primitive.
</p>
<p class="infotext" id="infotext">
  Click anywhere to inspect displacement map
</p>

<svg class="glitch" width="100%" height="100%" viewBox="0 0 800 160">
  <defs>
    <filter id="simpleglitchfilter" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB" preserveAspectRatio="none">
      <feFlood width="100%" height="100%" flood-color="rgb(128, 0, 128" result="BASE-COLOR" />
      <feFlood width="100%" height="10" y="0" flood-color="rgb(255, 0, 128" result="X-TRANSFORM">
        <animate attributeName="y" values="0px; 150px; 40px; 110px; 0px" dur="2.5s" repeatCount="indefinite" begin="0" />
        <animate attributeName="height" values="10px; 30px; 15px; 40px; 10px;" dur="4s" repeatCount="indefinite" begin="0" />
      </feFlood>
      <feMerge result="MERGE">
        <feMergeNode in="BASE-COLOR" />
        <feMergeNode in="X-TRANSFORM" />
      </feMerge>
      <feDisplacementMap in="SourceGraphic" in2="MERGE" scale="8" xChannelSelector="R" yChannelSelector="B">
        <animate attributeName="scale" values="-8; 5.5; 0; 8; 4.5; 7; -4; -9; 5; -5.5; 19; -8" dur="6s" repeatCount="indefinite" begin="0" />
      </feDisplacementMap>
    </filter>
  </defs>
  <g filter="url(#simpleglitchfilter)">
    <rect width="100%" height="100%" fill="transparent" fill-opacity="0" />
    <text y="70%" x="50%" text-anchor="middle" letter-spacing="-.09em">
      SIMPLE GLITCH
    </text>
  </g>
</svg>
              
            
!

CSS

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

html {
    height: 100%;
}

p {
  margin-bottom: 1em;
  text-align: center
}

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

body {
    cursor: pointer;
    background: black;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    margin: 0;
    padding: 1.25em;
    height: 100%;
    color: white;
    font: 0.85em -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    min-width: 320px;
}

.glitch {
    position: relative;
    display: flex;
    justify-content: stretch;
    align-items: center;
    position: relative;
    width: 800px;
    height: 160px;
    font: 6em 'Josefin Sans', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    fill: white;
}
              
            
!

JS

              
                const info = document.getElementById("infotext");
const filter = document.getElementById("simpleglitchfilter");
const feDisplacementMap = document.querySelector("feDisplacementMap");
let fragment = new DocumentFragment();

const showDisplacementMap = () => {
  fragment.appendChild(feDisplacementMap);
  info.innerText = "Click anywhere to inspect displacement filter effect";
  document.removeEventListener("click", showDisplacementMap);
  document.addEventListener("click", showFilter);
};

const showFilter = () => {
  filter.appendChild(fragment);
  info.innerText = "Click anywhere to inspect displacement map";
  document.removeEventListener("click", showFilter);
  document.addEventListener("click", showDisplacementMap);
};

document.addEventListener("click", showDisplacementMap);

              
            
!
999px

Console