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

              
                <!-- 
As always, there’s probably a better way to do all this, but…
IOAFCP (It's Only a F***ing CodePen), so relax.

However, if you have constructive feedback, I'd love to hear it. I learn a lot from my mistakes and poor life choices.

Adopt, don't shop 🐈
 -->

              
            
!

CSS

              
                // I use Recursive for almost everything. I even use it in my coffee.
// https://github.com/arrowtype/recursive
// Thank you Stephen Nixon for font-weight fix. I didn't have it in there and it was fauxing the bold. Amateur mistake.
@font-face {
  font-family: recursive;
  font-display: swap;
  font-weight: 300 1000;
  src: url('https://assets.codepen.io/2468711/Recursive_VF_1.047.woff2') format('woff2');
}

// CSS variables are so cool. We’re going to change these in the script.
:root {
  --font-size: 1rem;
  --font-weight: 100;
  --top: 0;
  --left: 0;
  --color: #f67809;
  --opacity: .1;
  --background-color: #060606;
}

html {
  font-family: recursive, sans-serif;
  font-weight: 600;
  font-variation-settings:
    'MONO' 1; // I never had mono… or chicken pox.
}

body {
  position: relative;
  height: 100vh;
  overflow: hidden;
  background-color: var(--background-color);
  position: relative;
  
  // We’re going to put a texture over the whole shebang.
  // It looks cool without it too.
  &::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    // CodePen assets are neat.
    background-image: url(https://assets.codepen.io/2468711/cloth-cover.jpg);
    background-size: cover;
    opacity: .2;
  }
}

// This is the thing the choosen (LOL “choosen”) glyphs get plopped into… or is it “in to”? Whatever.
// The script will change these variables (CSS variables are still cool, 21 lines later)
span {
  padding: 0;
  line-height: 1;
  font-size: var(--font-size);
  position: absolute;
  top: var(--top);
  left: var(--left);
  color: var(--color);
  opacity: var(--opacity);
}

              
            
!

JS

              
                // Hmmmm. What glyphs do we want to use? I usually use cuss words, but I’ll tone it down.
const glyphs = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
// Colors? Sure, we can have 5, 3, 11, 666… There’s a lot out there. Have fun with it! (I hate when people say that).
const colors = ['#f67809', '#faf7db', '#060606'];
// Choose the main thing to put the stuff in. (The Stuff was a good movie.)
const main = document.querySelector('body');

/*
All right now, this is where my brain fails and I feel dumber. We need to decide the number glyphs that get plopped and the font size on the square pixelage, so it's evenly filled when the window is big, small, short, wide and the font isn't HUGE on itty bitty windows or too small on the BIG ones.
*/

// How big is that window?
const width = window.innerWidth;
const height = window.innerHeight;
// We want to know how big the room is in square footage… er, window and square pixelage.
const squarePixelage = width * height;
const ratio = Math.floor(squarePixelage / 30000);
const fillRatio = ratio + 20;

// Give us a random number. We can tell it how high we want to get.
const rand = max => Math.floor(Math.random() * max);

// Give the background a random color. I hope it’s a good one.
main.style = `
  --background-color: ${colors[rand(colors.length)]};
  --opacity: ${rand(100) / 100 + 0.1}
  `;

// The main event, plopping glyphs on the page.
function glyphIt(max) {
  // We’re only gonna do this so many times.
  for (let i = 0; i < max; i++) {
    // Let’s get a random glyph
    const glyph = glyphs[rand(glyphs.length)];
    // OK, let's style that glyph with some random choices and make some HTML, a programming language.
    const glyphElement = `
      <span style="
        --font-size: ${rand(fillRatio) + 5}rem;
        --font-weight: ${300 + rand(700)};
        --top: ${rand(height + 300) - 300}px;
        --left: ${rand(width + 300) - 300}px;
        --color: ${colors[rand(colors.length)]};
        --opacity: ${rand(100) / 100 + 0.1}
      ">
        ${glyph}
      </span>
    `;
    // Here we go, puttin’ it on the page or whatever.
    main.insertAdjacentHTML('beforeend', glyphElement);
  }
}

// Yup, we’re gonna do this. How many times?
// This is based on window size (see notes above).
// You could also replace the parameter with a number, multiple it, divide it, randomize it…. Neat thing about things is you can do many things or nothing.
glyphIt(fillRatio);

// Let’s do this! Ready‽ Oh, we already did.

// Thanks for stopping by! I hope you like this or at least I helped you exercise your eye muscles while you rolled them. I made this on my birthday, more fun than having a party.

              
            
!
999px

Console