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

              
                <input id='textField' name="text" value="Write a word">Write a word</input>

<div id='letters'>
  <link rel="preconnect" href="https://fonts.gstatic.com">
  <link href="https://fonts.googleapis.com/css2?family=Monoton&family=Righteous&family=Sacramento&display=swap" rel="stylesheet">
  <div class='letters'></div>
</div>
              
            
!

CSS

              
                body {
  background-color: lightblue;
}

#textField {
  font-size: 2em;
  width: 99%;
}

#letters {
  width: 100%;
  height: 100%;
  font-family: "Monoton", cursive;
}

.letters {
  font-size: 2em;
  color: white;
  opacity: 0;
  position: absolute;
  top: 30%;
  left: 50%;
  transition: left 2000ms ease-in-out, top 2000ms ease-in-out,
    font-size 2000ms ease-in-out, color 2000ms ease-in-out,
    opacity 2000ms ease-in-out;
}

              
            
!

JS

              
                let text = document.querySelector("#textField");

console.log(text.value);

text.addEventListener("keyup", function (event) {
  if (event.keyCode === 13) {
    console.log("submit");
    changeText();
    event.preventDefault();
  }
});

//uncomment to separate by word
//let letter = ["l", "e", "t"];
let letterDivs = [];

function changeText() {
  //remove next two lines to separate by letter
  let string = text.value;
  let letter = string.split(" ");
  letters = [];
  letters = Array.from(letter);
  letters.forEach((letter) => {
    console.log(letter);
    let ldiv = document.createElement("div");
    ldiv.classList.add("letters");
    ldiv.innerHTML = letter;

    //starting positions
    let r = Math.random() * 100;
    let l = Math.random() * 100;
    ldiv.style.top = `${r}%`;
    ldiv.style.left = `${l}%`;

    letterDivs.push(ldiv);
    document.querySelector("#letters").appendChild(ldiv);
  });

  let letterTimer = setTimeout(randomizeParams, randomizeTimer());
  console.log(randomizeTimer());
}

//timer function
function randomizeTimer() {
  return Math.random() * 3500 + 500;
}

//random positions, size,
function randomizeParams() {
  letterDivs.forEach((ldiv) => {
    //position
    let r = Math.random() * 50 + 15;
    let s = Math.random() * 75;
    ldiv.style.top = `${r}%`;
    ldiv.style.left = `${s}%`;
    //size
    let t = Math.random() * 250 + 50;
    ldiv.style.fontSize = `${t}px`;
    //opacity
    function toggle() {
      let rand = Math.random();
      if (rand >= 0.5) {
        return 1;
      } else {
        return 0;
      }
    }
    ldiv.style.opacity = toggle();
    //color
    let x = "0123456789ABCDEF".split("");
    let color = "#";
    for (let i = 0; i < 6; i++) {
      color += x[Math.floor(Math.random() * 16)];
    }
    ldiv.style.color = color;
  });

  let letterTimer = setTimeout(randomizeParams, randomizeTimer());
  console.log(randomizeTimer());
}

              
            
!
999px

Console