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. 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

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

              
                <div class="scene">
  <div class="dotAndDash">
    <div class="dot"></div>
    <div class="dash">
      <div class="front"></div>
      <div class="right"></div>
      <div class="back"></div>
      <div class="left"></div>
      <div class="top"></div>
      <div class="bottom"></div>
    </div>
    <div class="dash-shadow"></div>
  </div>
  <div class="floor"></div>
</div>

              
            
!

CSS

              
                *, *::before, *::after {
  padding: 0;
  margin: 0 auto;
  box-sizing: border-box;
  transform-style: preserve-3d;
}

$speed: 6s;
$bp: 12;
$brickClr: maroon;
$brickMid: darken(maroon, 4%);
$brickLine: darken(maroon, 15%);

body {
  background-color: #333;
  background-image: linear-gradient(#202, #000 70%);
  color: #fff;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 80px;
  overflow: hidden;
  perspective: 15em;
  perspective-origin: 50% calc(50% - 3em);
}

.scene {
  position: relative;
  animation: scene_move $speed*7.1 infinite ease-in-out alternate;

  @keyframes scene_move {
    from { transform: rotateY(-20deg); }
    to   { transform: rotateY(20deg); }
  }
}

.dotAndDash {
  position: absolute;
  animation: scene_left $speed infinite linear;

  @keyframes scene_left {
    from { left: 2em; }
    to   { left: -2em; }
  }
}

.dot {
  position: absolute;
  top: 1.5em; left: -0.5em;
  width: 1em; height: 1em;
  border-radius: 50%;
  transform: rotateY(20deg);
  background-image:
    radial-gradient(circle, #000d, #0000),
    radial-gradient(circle, lightblue, #000);
  background-size: 400% 200%, 100% 200%;
  animation:
    dot_left $speed infinite ease-in-out,
    dot_topShadow $speed infinite ease-in-out,
    scene_move $speed*7.1 infinite ease-in-out alternate-reverse;


  @keyframes dot_left {
    0% { left: -0.5em; } 
    #{35 - $bp + "%"} { left: -0.85em; } 
    #{35 + $bp + "%"} { left: -0.15em; }
    70% { left: -0.5em; }
    100% { left: 3.5em; }
  }

  @keyframes dot_topShadow {
    0%, 100% { background-position: 100% 100%, 50% 100%; } 
    70% { background-position: 0% 100%, 50% 100%; } 
  }

  &::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 1.5em; height: 1.5em;
    transform: translate(-50%, -50%) rotateX(90deg) translateZ(-0.5em);
    background-image: radial-gradient(#000a, #0000 50%);
  }
}

.dash {
  position: absolute;
  width: 1em; height: 4em;
  animation:
    dash_transform $speed infinite ease-in-out,
    dash_origin $speed infinite step-end,
    dash_top $speed infinite ease-in,
    dash_left $speed infinite linear;

  & > * {
    position: absolute;
    background-color: lightblue;
    opacity: 0.8;
    box-shadow: 0 0 0.25em #000 inset;
  }

  .front {
    top: 0; left: 0;
    width: 100%; height: 100%;
    transform: translateZ(0.5em);
    overflow: hidden;

    &::after {
      content: '';
      position: absolute;
      top: -25%; left: -200%;
      width: 500%; height: 150%;
      background-image: linear-gradient(#0000, #000);
      animation: frontSpin $speed infinite ease-in-out;
    }

    @keyframes frontSpin {
      0% { transform: rotate(0deg); }
      70%, 100% { transform: rotate(-180deg); }
    }
  }

  .right {
    top: 0; left: 0;
    width: 100%; height: 100%;
    transform: rotateY(90deg) translateZ(0.5em);
    overflow: hidden;

    &::after {
      content: '';
      position: absolute;
      top: -25%; left: -200%;
      width: 500%; height: 150%;
      background-image: linear-gradient(#0000, #000);
      animation: frontSpin $speed infinite ease-in-out;
    }
  }

  .back {
    top: 0; left: 0;
    width: 100%; height: 100%;
    transform: rotateY(180deg) translateZ(0.5em);
  }

  .left {
    top: 0; left: 0;
    width: 100%; height: 100%;
    transform: rotateY(270deg) translateZ(0.5em);
    overflow: hidden;

    &::after {
      content: '';
      position: absolute;
      top: -25%; left: -200%;
      width: 500%; height: 150%;
      background-image: linear-gradient(#0000, #000);
      animation: frontSpin $speed infinite ease-in-out;
    }
  }

  .top {
    top: 0; left: 0;
    width: 100%; height: 1em;
    transform: rotateX(90deg) translateZ(0.5em);
    animation: topOpacity $speed infinite ease-in;

    @keyframes topOpacity {
      0% { opacity: 0.8; background-color: lightblue; }
      70%, 100% { opacity: 0; background-color: black;}
    }
  }

  .bottom {
    bottom: 0; left: 0;
    width: 100%; height: 1em;
    transform: rotateX(90deg) translateZ(-0.5em);
    animation: bottomOpacity $speed infinite ease-out;

    @keyframes bottomOpacity {
      0% { opacity: 0; background-color: black; }
      70%, 100% { opacity: 0.8; background-color: lightblue; }
    }
  }

  @keyframes dash_transform {
    0% { transform: translate(-50%, -50%) rotateZ(0deg); }
    70% { transform: translate(-50%, -50%) rotateZ(180deg); }
    75% { transform: translate(-50%, -50%) rotateZ(180deg) scaleY(0.8); }
    95%, 100% { transform: translate(-50%, -50%) rotateZ(180deg); animation-timing-function: ease-out; }
    97.5% { transform: translate(-50%, -50%) rotateZ(180deg) scaleY(0.9); animation-timing-function: ease-in-out; }
  }

  @keyframes dash_left {
    0%, #{35 - $bp + "%"} { left: -2em; }
    35% { left: -2.5em; }
    35.0001% { left: 1.5em; }
    #{35 + $bp + "%"}, 100% { left: 1em; }
  }
  @keyframes dash_top {
    0%, #{35 - $bp + "%"} { top: 0.5em; }
    35% { top: -0.5em; }
    35.0001% { top: 3.5em; animation-timing-function: ease-out; }
    #{35 + $bp + "%"}, 75%, 95%, 100% { top: 4.5em; animation-timing-function: ease-out; }
    85% { top: 3em; animation-timing-function: ease-in; }
  }
  @keyframes dash_origin {
    0% { transform-origin: 100% 100%; }
    35% { transform-origin: 100% 0%; }
  }

  &-shadow {
    position: absolute;
    height: 1.2em;
    background-color: #0007;
    transform: rotateX(90deg) translateZ(-1.9em);
    filter: blur(0.2em);
    animation:
      dash_shadow_left $speed infinite cubic-bezier(.75,0,.85,1),
      dash_shadow_right $speed infinite cubic-bezier(.15,0,.25,1),
      dash_shadow_opacity $speed infinite cubic-bezier(.15,0,.25,1);

    @keyframes dash_shadow_left {
      0% { left: -2.6em; }
      70%, 100% { left: 1.4em; }
    }

    @keyframes dash_shadow_right {
      0% { right: 1.4em; }
      70%, 100% { right: -2.6em; }
    }
    @keyframes dash_shadow_opacity {
      0%, 70%, 80%, 90%, 100% { opacity: 0.8; }
      35% { opacity: 0.4; }
      85% { opacity: 0.7; }
    }
  }
}

.floor {
  position: absolute;
  top: 1px; left: 0;
  width: 65em; height: 5em;
  background-color: $brickClr;
  background-image:
    linear-gradient(#0002, #fff2),
    radial-gradient(circle at 25% 25%, $brickMid, $brickClr calc(0.5em - 2px), #0000 0.2em),
    radial-gradient(circle at 75% 75%, $brickMid, $brickClr calc(0.5em - 2px), #0000 0.2em),
    repeating-linear-gradient(90deg, #0000 0 calc(0.5em - 2px), $brickLine calc(0.5em - 2px) calc(0.5em + 2px), #0000 calc(0.5em + 2px) 1em),
    repeating-linear-gradient(#0000 0 calc(0.5em - 2px), $brickLine calc(0.5em - 2px) calc(0.5em + 2px), #0000 calc(0.5em + 2px) 1em);
  transform: translateX(-50%) rotateX(90deg);
  background-position: top center;
  background-size: 100%, 2em 2em, 2em 2em, 100%, 100%;
  animation: scene_left $speed infinite linear;

  &::after {
    content: '';
    position: absolute;
    top: 100%; left: 0;
    width: 100%; height: 3em;
    background-color: $brickClr;
    transform: rotateX(-90deg);
    transform-origin: top;
    background-image:
      linear-gradient(#fff1, #000),
      radial-gradient(circle at 25% 0%, $brickMid, $brickClr calc(0.5em - 2px), #0000 0.2em),
      radial-gradient(circle at 25% 100%, $brickMid, $brickClr calc(0.5em - 2px), #0000 0.2em),
      radial-gradient(circle at 75% 50%, $brickMid, $brickClr calc(0.5em - 2px), #0000 0.2em),
      repeating-linear-gradient(90deg, #0000 0 calc(0.5em - 2px), $brickLine calc(0.5em - 2px) calc(0.5em + 2px), #0000 calc(0.5em + 2px) 1em),
      repeating-linear-gradient(#0000 0 calc(1em - 2px), $brickLine calc(1em - 2px) 1em);
    background-size: 100%, 2em 2em, 2em 2em, 2em 2em, 100%, 100%;
    background-position: top center;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console