Pen Settings

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="title" data-splitting="lines">
  SPACE<br/>
  INVADERS
</div>
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Coda+Caption:800');

html, body { background: hsl(220, 70%, 30%); }
html { height: 100%; display: flex; }
body { margin: auto; }

/*
  You can adjust the
    * rotation (rotateX),
    * vertical stretch (scaleY),
    * projection (perspective) and
    * layer depth (--layer-depth)
*/
.title {
  text-align: center;
  font-family: 'Coda Caption', sans-serif;
  font-weight: 800;
  font-size: calc(20vw / var(--word-total) ); /* Overriden below for fluid typography test */
  line-height: 1.0;
  letter-spacing: -0.03em;
  transform: perspective(300px) scaleY(1.5) rotateX(-40deg);
  transform-style: preserve-3d; /* Important for establishing a shared 3D space for all the layers */
  --layer-depth: 0.32em;
}


/* The front layer are yellow words with a thick black stroke outline */
.title .word {
  position: relative;
  display: inline-block;
  color: yellow;
  font-size: calc(((var(--line-index) + 1) * 25%) + 50%); /* We skew font-sizes to avoid emphasize on the top, due to perspective rotation */
  text-shadow: 0.06em 0 black, 0.06em 0.06em black, 0 0.06em black, -0.06em 0.06em black, -0.06em 0 black, -0.06em -0.06em black, 0 -0.06em black, 0.06em -0.06em black;
  transform-style: preserve-3d; /* Important as above, we need to make sure the pseudos share the same 3D space */
}


/* The back layers are two pseudos, we pull content through via Splitting.js! */
.title .word::before,
.title .word::after {
  content: attr(data-word);
  position: absolute;
  top: auto;
  left: 0;
  bottom: 0;
  display: block;
  pointer-events: none;
}

/* Red layer immediately behind the yellow, thinner stroke outline */
.title .word::before {
  color: red;
  text-shadow: 0.02em 0 black, 0.02em 0.02em black, 0 0.02em black, -0.02em 0.02em black, -0.02em 0 black, -0.02em -0.02em black, 0 -0.02em black, 0.02em -0.02em black;
  transform: translateZ(calc(var(--layer-depth) * -0.5));
}

/* Furthest layer, just simple black lettering with no outline */
.title .word::after {
  color: black;
  text-shadow: none;
  transform: translateZ(calc(var(--layer-depth) * -1));
}


/* Testing Fluid Typography with CSS Variables – Broke on Safari though? */
.title {
  --min-font-size: 64;
  --max-font-size: 128;
  font-size: calc(var(--min-font-size) * 1px);
}

@media screen and (min-width: 320px) {
  .title {
    font-size: calc(var(--min-font-size) * 1px + (var(--max-font-size) - var(--min-font-size)) * ((100vw - 320px) / 680));
  }
}

@media screen and (min-width: 1000px) {
  .title {
    font-size: calc(var(--max-font-size) * 1px);
  }
}

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console