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

              
                #controller
  .scene
    .inner
      .text The width of the red bar controls the ghost's movement
      #indicator.text
    .ghost
      .ec
        .eye
        .eye
      - for(var i=0;i<3;i++)
        .frill

              
            
!

CSS

              
                :root {
  --bw: 18vw;
  --bt: 5s;
}

#indicator::after {
  display: block;
  margin-top: -2vw;
  content: "";
}

body {
  background: black;
}

#controller {
  position: absolute;
  top: 47vw;
  left: 2vw;
  width: 2vw;
  height: 5vw;
  background: red;
  container: mc / inline-size;
  animation: grow infinite linear calc(var(--bt) * 4);
}

@container mc (min-width: 1vw) {
  .ghost {
    animation: go-right-g 1 calc(var(--bt) - 0.9s) linear forwards;
  }
  #indicator::after {
    content: "GOING RIGHT";
  }
}

@container mc (min-width: 18vw) {
  .ghost {
    animation: go-down-g calc(var(--bt) - 0.5s) 1 linear forwards;
  }
  #indicator::after {
    content: "GOING DOWN";
  }
}

@container mc (min-width: 36vw) {
  .ghost {
    animation: go-left-g calc(var(--bt) - 0.5s) 1 linear forwards;
  }
  #indicator::after {
    content: "GOING LEFT";
  }
}

@container mc (min-width: 54vw) {
  .ghost {
    animation: go-up-g calc(var(--bt) - 0.5s) 1 linear forwards;
  }
  #indicator::after {
    content: "GOING UP";
  }
}

@keyframes go-right-h {
  from {
    left: 13vw;
  }
  to {
    left: 86vw;
  }
}

@keyframes go-right-g {
  from {
    left: 3vw;
  }
  to {
    left: 86vw;
  }
}

@keyframes go-down-g {
  from {
    left: 86vw;
    top: 2vw;
  }
  to {
    left: 86vw;
    top: 33vw;
  }
}

@keyframes go-left-g {
  from {
    left: 86vw;
    top: 33vw;
  }
  to {
    left: 3vw;
    top: 33vw;
  }
}

@keyframes go-up-g {
  from {
    left: 3vw;
    top: 33vw;
  }
  to {
    left: 3vw;
    top: 2vw;
  }
}

@keyframes grow {
  from {
    width: 0vw;
  }
  to {
    width: calc(var(--bw) * 4);
  }
}

.scene {
  position: absolute;
  width: 95vw;
  height: 41vw;
  left: 0vw;
  top: -44vw;
  border: solid #2f922f;
  border-radius: 2vw;
  box-shadow: 0 0 2vw green;
  background-image: repeating-radial-gradient(
    circle,
    white 20%,
    black 25%,
    black 100%
  );
  background-size: 3vw 3vw;
}

.inner {
  position: absolute;
  width: 70vw;
  height: 21vw;
  border: solid #2f922f;
  border-radius: 2vw;
  box-shadow: 0 0 2vw green;
  left: 12vw;
  top: 9vw;
  background: black;
}

.hero {
  position: relative;
  top: 2vw;
  left: 13vw;
}

.ghost {
  position: relative;
  width: 6vw;
  height: 5vw;
  background: blue;
  left: 3vw;
  top: 2vw;
  border-radius: 6vw 6vw 0 0;
  box-shadow: 0 0 1vw blue;
}

.frill {
  background: blue;
  width: 1.4vw;
  height: 1.7vw;
  float: left;
  margin-top: 1.3vw;
  margin-left: 0.5vw;
  transform: rotate(45deg);
  box-shadow: 0 0 1vw blue;
}

.eye {
  width: 0.6vw;
  height: 0.6vw;
  background: black;
  border: solid white 0.9vw;
  border-radius: 100%;
  float: left;
  margin-top: 0.5vw;
  margin-left: 0.2vw;
}

.ec {
  margin-left: 0.5vw;
  animation: look 0.1s infinite alternate linear;
}

@keyframes look {
  from {
    margin-left: 0.5vw;
  }
  to {
    margin-left: 0;
  }
}

.text {
  color: green;
  font-family: "VT323", monospace;
  font-size: 5vw;
  padding: 2vw;
}

              
            
!

JS

              
                
              
            
!
999px

Console