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

              
                <input class="input" type="text" id="input" value="" autocomplete="off" placeholder="Type something...">
  <div id="container">
    <svg viewBox="0 0 90 90" xmlns="http://www.w3.org/2000/svg" id="template">
      <defs>
      <filter id="a">
        <feGaussianBlur stdDeviation="2.16856"/>
      </filter>
      </defs>
      <path transform="matrix(1.0906 0 0 1.0702 -5.1986 -3.458)" d="m33.031 8.6875c-7.0545 0.06801-14.169 3.1836-18.562 9.4062-9.3863 13.293-2.3038 31.359 6.125 31.75 4.8678 0.22555 15.124-3.9054 23.899 12.099 5.1049 9.3116 16.092 0.51875 20.164 0.21301 13.006-0.9766 17.062 19.719 17.062 19.719s-2.082-27.083-8.9688-34.719c-4.6157-5.1176-12.282-1.7067-16.031-8.375s-1.4206-13.606-3.9062-18.594c-3.8507-7.7268-11.786-11.577-19.781-11.5zm11.655 25.247c-3.395 1.3247-21.104-11.818-13.553-16.266s18.016 11.731 13.553 16.266zm-14.698 5.966c-3.395 6.0709-17.359-11.631-11.207-16.434s13.815 13.408 11.207 16.434zm22.7 7.3062c-6.3296 7.8794-19.036-7.6155-17.72-12.769 5.5711 0.65766 17.286 6.6861 17.72 12.769z" fill="#fff" filter="url(#a)" opacity=".6"/>
    </svg>
  </div>
              
            
!

CSS

              
                * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #000;
}

svg {
  position: absolute;
  width: 200px;
  animation: moveGhosts 4s linear;
  animation-direction: reverse;
};

#ghosts-container {
  position: relative;
}

#template {
  display: none;
}

input {
  position: absolute;
  display: block;
  padding: 12px 6px;
  border: none;
  border-radius: 5px;
  font-size: 30px;
  text-align: center;
  box-shadow: 0 0 30px 7px rgba(0, 0, 0, 0.2);
}

@keyframes moveGhosts {
  to {
    top: 100vh;
    opacity: 0.4;
  }
}
              
            
!

JS

              
                let ww = window.innerWidth;
let wh = window.innerHeight;

let ghosts = document.getElementById("container");
let ghostTemplate = document.getElementById("template");
let input = document.getElementById("input");
input.addEventListener("input", run)
input.addEventListener("click", run)
input.addEventListener("focus", run)

function createGhosts() {
  let newGhost = ghostTemplate.cloneNode(true);
  newGhost.removeAttribute("id");
  let orientation = (Math.random() > 0.5) ? 1 : -1;
  newGhost.style.transform = `scale(${orientation}, 1) rotate(45deg)`;
  newGhost.style.left = getRandomNumber(0, ww) - 100 + "px";
  console.log(newGhost.style.left)
  newGhost.style.top = wh * (-(Math.random() + 0.5) * 2) + "px";
  newGhost.style.display = "block";
  ghosts.appendChild(newGhost)
}

function run() {
  for (let i = 0; i < 30; i += 1) {
    createGhosts();
    input.value = "Booooo!!";
  }
  input.removeEventListener("input", run);
  input.removeEventListener("click", run);
  input.removeEventListener("focus", run);
}

function getRandomNumber(min, max) {
  return Math.random() * (max - min) - min;
}
              
            
!
999px

Console