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

              
                <h1>
  SVG Turbulence Filter Test
</h1>
<p id="sentence" contenteditable="true" spellcheck="false">
  The <strong>feTurbulence</strong> SVG filter generates and renders <em>Perlin noise</em>. This can be used
  by CSS to distort <strong>elements and text</strong>. Try selecting or editing <em>this text</em>. You can fiddle
  with the sliders below to <strong>change the effect</strong>.
</p>

<div class="sliders">
  <div class="slider">
    <label for="turbulenceNumOctavesRange">Turbulence Number of Octaves</label>
    <output for="turbulenceNumOctavesRange" id="turbulenceNumOctavesRangeOutput"></output>
    <input class="slider__range" type="range" name="turbulenceNumOctavesRange" id="turbulenceNumOctavesRange" data-filter-id="turbulence" data-filter-attr="numOctaves" min="1" max="9" value="5" />
  </div>
  <div class="slider">
    <label for="turbulenceBaseFrequencyRange">Turbulence Base Frequency</label>
    <output for="turbulenceBaseFrequencyRange" id="turbulenceBaseFrequencyRangeOutput"></output>
    <input class="slider__range" type="range" name="turbulenceBaseFrequencyRange" id="turbulenceBaseFrequencyRange" data-filter-id="turbulence" data-filter-attr="baseFrequency" min="0.0001" max="0.002" step="0.0001" value="0.0002" />
  </div>
  <div class="slider">
    <label for="turbulenceBaseSeedRange">Turbulence Seed</label>
    <output for="turbulenceBaseSeedRange" id="turbulenceBaseSeedRangeOutput"></output>
    <input class="slider__range" type="range" name="turbulenceBaseSeedRange" id="turbulenceBaseSeedRange" data-filter-id="turbulence" data-filter-attr="seed" min="0" max="1000" step="1" value="500" />
  </div>
  <div class="slider">
    <label for="displacerScaleRange">Displacer Scale</label>
    <output for="displacerScaleRange" id="displacerScaleRangeOutput"></output>
    <input class="slider__range" type="range" name="displacerScaleRange" id="displacerScaleRange" data-filter-id="displacer" data-filter-attr="scale" min="1" max="100" value="50" />
  </div>
</div>

<svg class="filter">
  <defs>
    <filter id="filter">
      <feTurbulence id="turbulence" type="fractalNoise" baseFrequency="0.0001 " numOctaves="5" result="NOISE">
      </feTurbulence>
      <feGaussianBlur in="SourceGraphic" result="BLURRED" stdDeviation="0"></feGaussianBlur>
      <feDisplacementMap id="displacer" in2="NOISE" in="BLURRED" scale="15" xChannelSelector="R" yChannelSelector="R" result="DISPLACED"></feDisplacementMap>
    </filter>
  </defs>
  
</svg>
              
            
!

CSS

              
                :root {
  --color-surface: Black;
  --color-background: PaleGoldenRod;
}

/* Box sizing rules */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Remove default margin */
body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
  font-size: 100%;
}

html {
  height: 100vh;
  line-height: 1.3;
  font-size: 87.5%;
  font-weight: 600;
  text-transform: uppercase;
  font-family: ui-monospace, Menlo, Monaco, "Cascadia Mono", "Segoe UI Mono",
    "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace", "Source Code Pro",
    "Fira Mono", "Droid Sans Mono", "Courier New", monospace;
  display: grid;
  place-items: center;
  color: var(--color-surface);
  background-color: var(--color-background);
}

body {
  padding: 2rem;
  max-width: 74rem;
}

::selection {
  background: var(--color-surface);
  color: var(--color-background);
}

*:focus {
  outline: none;
}

*:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

h1 {
  margin-bottom: 2rem;
}

p {
  font-size: 4rem;
  font-size: clamp(2rem, 0.9349rem + 4.1420vw, 4rem);
  font-weight: normal;
  filter: url(#filter);
  border: 3px solid currentColor;
  padding: 0.75em;
  font-family: "Bebas Neue", sans-serif;
}

em {
  font-style: normal;
  font-weight: normal;
  text-decoration: underline;
  text-decoration-thickness: 0.1em;
  text-underline-offset: 0.05em;
}

strong {
  font-weight: normal;
  background-color: var(--color-surface);
  color: var(--color-background);
  padding: 0 0.25em;
}

label,
output,
h1 {
  font-size: inherit;
}

/* style for the range input */
input[type="range"] {
  --range__thumb-size: 1.5em;
  --range__border-width: 3px;
  --range__thumb-bgc: var(--color-background);
  -webkit-appearance: none;
  margin: 1em 0;
  width: 100%;
  display: block;
  color: inherit;
  background-color: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: var(--range__border-width);
  cursor: pointer;
  background: currentColor;
  border: 0px solid currentColor;
}

input[type="range"]::-webkit-slider-thumb {
  border: var(--range__border-width) solid currentColor;
  height: var(--range__thumb-size);
  width: var(--range__thumb-size);
  background: var(--range__thumb-bgc);
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: calc(
    -1 * calc(var(--range__thumb-size) / 2) + 1 * calc(var(
            --range__border-width
          ) / 2)
  );
}

input[type="range"]::-moz-range-track {
  width: 100%;
  height: var(--range__border-width);
  cursor: pointer;
  background: currentColor;
  border: 0px solid currentColor;
}

input[type="range"]::-moz-range-thumb {
  border-radius: 0;
  border: var(--range__border-width) solid currentColor;
  height: var(--range__thumb-size);
  width: var(--range__thumb-size);
  background: var(--range__thumb-bgc);
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: calc(
    -1 * calc(var(--range__thumb-size) / 2) + 1 * calc(var(
            --range__border-width
          ) / 2)
  );
}

.sliders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem 3rem;
}

.slider {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.5rem;
}

.slider input[type="range"] {
  grid-column: 1 / -1;
  grid-row: 2;
}

* + .sliders {
  margin-top: 3rem;
}

.filter {
  position: absolute !important;
  height: 1px; width: 1px; 
  overflow: hidden;
  clip: rect(1px 1px 1px 1px); 
  clip: rect(1px, 1px, 1px, 1px);
}

              
            
!

JS

              
                // set the value of the element turbulenceBaseSeedRange to a random number between 0 and 1000
document.getElementById("turbulenceBaseSeedRange").value = Math.floor(
  Math.random() * 1000
);
// set each atrribute of the filter of the svg element to the values of the corresponding range inputs based on the data-filter-id and data-filter-attr attributes and set the output element's value to the value of the range input when the input's value changes
const sliders = document.querySelectorAll(".slider__range");
const filter = document.querySelector(".filter");
sliders.forEach((slider) => {
  // set the output element to the value of the range input
  const output = slider.parentNode.querySelector("output");
  output.value = slider.value;
  const filterId = slider.dataset.filterId;
  const filterAttr = slider.dataset.filterAttr;
  const filterElement = filter.querySelector(`#${filterId}`);
  filterElement.setAttribute(filterAttr, slider.value);
  slider.addEventListener("input", function () {
    output.value = this.value;
    filterElement.setAttribute(filterAttr, this.value);
  });
});

              
            
!
999px

Console