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

              
                <div class="range-container">
  <p class="mono">Settings</p>
  <div class="range-control">
    <label>Character solve time</label>
    <p>The amount of time in milliseconds that each character animates for.</p>
    <input type="range" id="solve" min="1" max="1600">
    <div class="range-value-container">
      <span id="solve-time-value" class="range-value mono">23</span>
    </div>
  </div>

  <div class="range-control">
    <label>Character selection time</label>
    <p>The amount of time in milliseconds that determines how often a random character is displayed.</p>
    <input type="range" id="spin" min="1" max="80">
    <div class="range-value-container">
      <span id="selection-time-value" class="range-value mono">23</span>
    </div>
  </div>

  <div class="range-control">
    <label>Next character delay</label>
    <p>The amount of time in milliseconds to wait before animating the next charcter in the string.</p>
    <input type="range" id="delay" min="1" max="500">
    <div class="range-value-container">
      <span id="delay-time-value" class="range-value mono">23</span>
    </div>
  </div>

  <div class="range-control">
    <label>Characters</label>
    <input type="text" id="characters" maxlength="18">
  </div>

  <div class="result">
    <p class="mono">Result</p>
    <a id="result-characters" href="#" class="cipher">Hover Me!</a>
  </div>
</div>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Space+Mono&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@500;600&display=swap");

body {
  align-items: center;
  background-color: #13223b;
  display: flex;
  flex-direction: column;
  font-family: "Poppins", sans-serif;
  height: 100vh;
  justify-content: center;

  a {
    color: #ffdd40;
    display: block;
    font-family: "Space Mono", monospace;
    font-size: 26px;
    letter-spacing: 5px;
    margin: 0 10px 6px 10px;
    padding: 2px 12px 6px 19px;
    position: relative;
    text-decoration: none;
    text-shadow: #a68800 1px 0 10px;
  }

  .range-container {
    background-color: #1d345a;
    border: 1px solid #055eb4;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: scroll;
    width: 450px;

    label {
      color: #6db7ff;
      display: block;
      font-size: 18px;
      font-weight: 600;
    }

    p {
      color: white;
      font-size: 14px;
      margin-top: 8px;
    }

    .mono {
      font-family: "Space Mono", monospace;
      font-size: 20px;
      margin: 12px 0 0 0;
      text-align: center;
    }

    .range-control {
      padding: 5px 20px;
      position: relative;

      .range-value {
        align-items: center;
        background-color: #022547;
        border: 1px solid #055eb4;
        border-radius: 4px;
        bottom: -28px;
        color: #ffdd40;
        display: flex;
        font-size: 14px;
        height: 25px;
        justify-content: center;
        padding: 0 9px;
        position: absolute;
        right: 18px;
        width: 30px;
      }
    }

    .result {
      align-items: center;
      background-color: #13223b;
      border-top: 1px solid #055eb4;
      display: flex;
      flex-direction: column;
      margin-top: 10px;
    }
  }

  input[type="text"] {
    appearance: none;
    background-color: #022547;
    border: 1px solid #055eb4;
    border-radius: 4px;
    box-sizing: border-box;
    color: #ffdd40;
    font-family: "Space Mono", monospace;
    font-size: 17px;
    margin-top: 8px;
    outline: none;
    padding: 8px 12px;
    transition: opacity 300ms ease-in-out;
    -webkit-appearance: none;
    width: 100%;

    &:focus {
      border-color: #6db7ff;
    }

    &:disabled {
      opacity: 50%;
    }
  }

  input[type="range"] {
    appearance: none;
    background: transparent;
    cursor: pointer;
    transition: opacity 300ms ease-in-out;
    -webkit-appearance: none;
    width: 100%;

    &:focus {
      outline: none;
    }

    &:disabled {
      opacity: 50%;
    }

    /* Chrome, Safari, Opera and Edge Chromium */
    &::-webkit-slider-runnable-track {
      background-color: #022547;
      border: 1px solid #055eb4;
      border-radius: 4px;
      height: 6px;
    }

    &::-webkit-slider-thumb {
      appearance: none;
      background-color: #6db7ff;
      border: 1px solid #055eb4;
      border-radius: 50px;
      height: 20px;
      margin-top: -12px;
      -webkit-appearance: none;
      width: 20px;
    }

    &:focus::-webkit-slider-thumb {
      border: 1px solid #055eb4;
      outline: 2px solid #ffdd40;
      outline-offset: 3px;
    }

    /* Firefox */
    &::-moz-range-track {
      background-color: #022547;
      border: 1px solid #055eb4;
      border-radius: 4px;
      height: 6px;
    }

    &::-moz-range-thumb {
      background-color: #6db7ff;
      border: 1px solid #055eb4;
      border-radius: 50px;
      height: 20px;
      width: 20px;
    }

    &:focus::-moz-range-thumb {
      background-color: #ffdd40;
      border: 1px solid transparent;
      outline: 2px solid #ffdd40;
      outline-offset: 3px;
    }
  }
}

              
            
!

JS

              
                const characters = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890*#@/*!%&^"];
const resultCharacters = document.querySelector("#result-characters");

const solveSlider = document.querySelector("#solve");
const selectionSlider = document.querySelector("#spin");
const delaySlider = document.querySelector("#delay");
const characterInput = document.querySelector("#characters");

const solveTimeContainer = document.querySelector("#solve-time-value");
const selectionTimeContainer = document.querySelector("#selection-time-value");
const delayTimeContainer = document.querySelector("#delay-time-value");

let solveMilliseconds = 800;
let characterSelectionMilliseconds = 40;
let delayMilliseconds = 250;

solveSlider.value = solveMilliseconds;
selectionSlider.value = characterSelectionMilliseconds;
delaySlider.value = delayMilliseconds;

solveTimeContainer.innerText = solveMilliseconds;
selectionTimeContainer.innerText = characterSelectionMilliseconds;
delayTimeContainer.innerText = delayMilliseconds;

characterInput.value = "Hover Me!";

const randomArrayElement = (arr) => {
  return arr[(arr.length * Math.random()) | 0];
};

solveSlider.addEventListener("input", (e) => {
  solveMilliseconds = parseInt(e.target.value, 10);
  solveTimeContainer.innerText = e.target.value;
});

selectionSlider.addEventListener("input", (e) => {
  characterSelectionMilliseconds = parseInt(e.target.value, 10);
  selectionTimeContainer.innerText = e.target.value;
});

delaySlider.addEventListener("input", (e) => {
  delayMilliseconds = parseInt(e.target.value, 10);
  delayTimeContainer.innerText = e.target.value;
});

resultCharacters.addEventListener("mouseenter", (e) => {
  const element = e.target;
  scrambleText(element);
  e.preventDefault();
});

characterInput.addEventListener("input", (e) => {
  resultCharacters.innerText = characterInput.value;
});

function scrambleText(element) {
  if (element.classList.contains("active") === false) {
    let delay = 0;
    const elementText = element.innerText;
    const elementCharacters = [...elementText];
    const lockMilliseconds =
      delayMilliseconds * elementCharacters.length + solveMilliseconds;

    element.classList.add("active");
    deactivateInputs();

    setTimeout(() => {
      element.classList.remove("active");
      activateInputs();
    }, lockMilliseconds);

    elementCharacters.forEach((character, index) => {
      setTimeout(
        () => {
          let intervalId = setInterval(() => {
            const randomCharacter = randomArrayElement(characters);
            element.innerText = replaceCharacter(
              element.innerText,
              index,
              randomCharacter
            );

            setTimeout(() => {
              clearInterval(intervalId);
              element.innerText = replaceCharacter(
                element.innerText,
                index,
                elementCharacters[index]
              );
            }, solveMilliseconds);
          }, characterSelectionMilliseconds);
        },
        delay === 0 ? (delay += 1) : (delay += delayMilliseconds)
      );
    });
  }
}

function deactivateInputs() {
  characterInput.disabled = true;
  solveSlider.disabled = true;
  selectionSlider.disabled = true;
  delaySlider.disabled = true;
}

function activateInputs() {
  characterInput.disabled = false;
  solveSlider.disabled = false;
  selectionSlider.disabled = false;
  delaySlider.disabled = false;
}

function replaceCharacter(str, index, chr) {
  return `${str.substring(0, index)}${chr}${str.substring(index + 1)}`;
}

              
            
!
999px

Console