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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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="outer">
  <div class="outer_scene">
    <div class="outer_floor"></div>
    <div class="balls">
      <div class="ball"></div>
      <div class="ball"></div>
      <div class="ball"></div>
      <div class="ball"></div>
    </div>
  </div>
</div>

<div class="portal">
  <div class="portal_scene">
    <div class="portal_floor"></div>

    <div class="cube">
      <div class="cube_shadow"></div>
      <div class="cube_body">
        <div></div><div></div><div></div><div></div><div></div><div></div>
      </div>
    </div>
    <div class="cube">
      <div class="cube_shadow"></div>
      <div class="cube_body">
        <div></div><div></div><div></div><div></div><div></div><div></div>
      </div>
    </div>
    <div class="cube">
      <div class="cube_shadow"></div>
      <div class="cube_body">
        <div></div><div></div><div></div><div></div><div></div><div></div>
      </div>
    </div>
    <div class="cube">
      <div class="cube_shadow"></div>
      <div class="cube_body">
        <div></div><div></div><div></div><div></div><div></div><div></div>
      </div>
    </div>
  </div>
</div>

<div class="outer">
  <div class="outer_scene">
    <div class="balls">
      <i></i>
      <i></i>
      <i></i>
      <i></i>
      <div class="ball"></div>
      <div class="ball"></div>
      <div class="ball"></div>
      <div class="ball"></div>
    </div>
  </div>
</div>

              
            
!

CSS

              
                *, *::before, *::after {
  padding: 0;
  margin: 0 auto;
  box-sizing: border-box;
}

body {
  background-color: #def;
  background-image: linear-gradient(#201, #001 50%);
  color: #fff;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;

  *:not(:empty), * {
    transform-style: preserve-3d;
  }
}

$speed: 9s;
$speed2: 4s;
$rAngle: 50deg;

.outer {
  position: absolute;
  top: 50%; left: 50%;
  perspective: 800px;

  &_scene {
    position: absolute;
    top: 50%; left: 50%;
    animation: sceneRotate $speed infinite ease-in-out alternate;
  }

  &_floor {
    position: absolute;
    top: 50%; left: 50%;
    width: 3200px; height: 3200px;
    transform: translate(-50%, -50%) rotateX(90deg) translateZ(-240px);
    background-color: #07a;
    background-image:
      radial-gradient(#111a, #1110, #001 60%),
      radial-gradient(#fff5 0, #fff0 15px);
    background-size: 100%, 30px 30px;
  }
}

.ball {
  position: absolute;
  top: 240px;
  width: 0; height: 0;
  transform-style: preserve-3d;
  animation: ballAngle $speed infinite ease-in-out alternate;

  $count: 8;
  @for $i from 0 to $count {
    &:nth-child(#{$i + 1}) {
      --ry: #{360deg / $count * $i + 112.5deg};
      --delay: #{$speed2 / $count * $i * -3};
      --hue: #{$i * 40};
    }
  }

  @keyframes ballAngle {
    from { transform: rotateY(var(--ry, 0)) translateZ(420px) rotateY(calc(var(--ry, 0) * -1)) rotateY($rAngle); }
    to   { transform: rotateY(var(--ry, 0)) translateZ(420px) rotateY(calc(var(--ry, 0) * -1)) rotateY($rAngle * -1); }
  }

  &::before {
    content: '';
    position: absolute;
    left: -120px; top: -120px;
    width: 240px; height: 240px;
    background-image: radial-gradient(#000, #0000 50%);
    animation: ballShadow $speed2 var(--delay, 0s) infinite;

    @keyframes ballShadow {
      0%, 50%, 100% { transform: rotateX(90deg) translateZ(1px) scale(1); opacity: 0.5; animation-timing-function: ease-out; }
      55%, 97% { transform: rotateX(90deg) translateZ(1px) scale(0.9); opacity: 0.5; animation-timing-function: ease-out; }
      75% { transform: rotateX(90deg) translateZ(1px) scale(2); opacity: 0; animation-timing-function: ease-in; }
      94% { transform: rotateX(90deg) translateZ(1px) scale(1.2); opacity: 0.5; animation-timing-function: ease-out; }
    } 
  }

  &::after {
    content: '';
    position: absolute;
    left: -60px; bottom: 0; 
    width: 120px; height: 120px;
    background-image: radial-gradient(circle at top, hsl(0, 100%, 75%), hsl(0, 100%, 0%));
    border-radius: 50%;
    transform-origin: bottom;
    animation: ballJump $speed2 var(--delay, 0s) infinite;

    @keyframes ballJump {
      0%, 50%, 100% { transform: scaleY(1) translateY(0px); animation-timing-function: ease-out; }
      55%, 97% { transform: scaleY(0.8) translateY(0px); animation-timing-function: ease-out; }
      75% { transform: scaleY(1) translateY(-420px); animation-timing-function: ease-in; }
      94% { transform: scaleY(1.2) translateY(0px); animation-timing-function: ease-out; }
    } 
  }
}

.portal {
  position: absolute;
  top: 50%; left: 50%;
  width: 420px; height: 420px;
  background-image: linear-gradient(#201, #000 50%);
  border-radius: 50%;
  box-shadow: 0 0 20px #f77, 0 0 50px #7ff;
  perspective: 660px;
  overflow: hidden;
  animation: portalRotate $speed infinite ease-in-out alternate;

  @keyframes portalRotate {
    from { transform: translate(-50%, -50%) rotateY($rAngle); }
    to { transform: translate(-50%, -50%) rotateY($rAngle * -1); }
  }

  &_scene {
    position: absolute;
    top: 50%; left: 50%;
    animation: sceneRotate $speed infinite ease-in-out alternate;

    @keyframes sceneRotate {
      from { transform: rotateY($rAngle * -1); }
      to { transform: rotateY($rAngle); }
    }    
  }

  &_floor {
    position: absolute;
    top: 50%; left: 50%;
    width: 3200px; height: 3200px;
    transform: translate(-50%, -50%) rotateX(90deg) translateZ(-240px);
    background-color: #444;
    background-image:
      radial-gradient(#111a, #1110, #000 60%),
      repeating-linear-gradient(#fff5 0 5px, #fff0 0 75px),
      repeating-linear-gradient(90deg, #fff5 0 5px, #fff0 0 75px);    
  }
}

.cube {
  position: absolute;
  top: 240px;
  transform: rotateY(var(--ry, 0)) translateZ(525px) rotateY(calc(var(--ry, 0) * -1));

  $count: 4;
  @for $i from 0 to $count {
    &:nth-child(#{$i + 2}) {
      --ry: #{180deg / $count * $i + 112.5deg};
      --delay: #{$speed2 / $count * $i * -1.5};
    }
  }

  &_body {
    position: absolute;
    left: -60px;
    width: 120px; height: 120px;
    transform-origin: bottom;
    animation:
      cubeBottom $speed2 var(--delay, 0s) infinite,
      cubeRotate $speed2 var(--delay, 0s) infinite;

    @keyframes cubeBottom {
      0%, 55%, 94%, 100% { bottom: 0px; animation-timing-function: ease-out; }
      75% { bottom: 420px; animation-timing-function: ease-in; }
    }

    @keyframes cubeRotate {
      0%, 50% { transform: scaleY(1) rotateY(0deg); animation-timing-function: ease-out; }
      55%     { transform: scaleY(0.8) rotateY(0deg); animation-timing-function: ease-in; }
      75%     { transform: scaleY(1) rotateY(240deg); animation-timing-function: ease-out; }
      94%     { transform: scaleY(1.2) rotateY(360deg); }
      97%     { transform: scaleY(0.8) rotateY(360deg); }
      100%    { transform: scaleY(1) rotateY(360deg); }
    }

    & > div {
      position: absolute;
      inset: 0;
      background-color: #fff;
      box-shadow:
        0 0 20px hsl(180, 100%, 25%) inset,
        0 0 50px hsl(180, 100%, 75%) inset;
      opacity: 0.8;

      &:nth-child(1) { transform: translateZ(60px); }
      &:nth-child(2) { transform: rotateY(90deg) translateZ(60px); }
      &:nth-child(3) { transform: rotateY(180deg) translateZ(60px); }
      &:nth-child(4) { transform: rotateY(270deg) translateZ(60px); }
      &:nth-child(5) { transform: rotateX(90deg) translateZ(60px); }
      &:nth-child(6) { transform: rotateX(270deg) translateZ(60px); }
    }
  }

  &_shadow {
    position: absolute;
    left: -70px; top: -70px;
    width: 140px; height: 140px;
    background-color: #0005;
    transform: rotateX(90deg) translateZ(1px);
    filter: blur(20px);
    animation: cubeShadow $speed2 var(--delay, 0s) infinite;

    @keyframes cubeShadow {
      0%, 50% { transform: rotateX(90deg) translateZ(1px) scaleY(1) rotateZ(0deg); opacity: 1; animation-timing-function: ease-out; }
      55%     { transform: rotateX(90deg) translateZ(1px) scaleY(0.8) rotateZ(0deg); opacity: 1; animation-timing-function: ease-in; }
      75%     { transform: rotateX(90deg) translateZ(1px) scaleY(3) rotateZ(-240deg); opacity: 0.4; animation-timing-function: ease-out; }
      94%     { transform: rotateX(90deg) translateZ(1px) scaleY(1.2) rotateZ(-360deg); opacity: 1; }
      97%     { transform: rotateX(90deg) translateZ(1px) scaleY(0.8) rotateZ(-360deg); opacity: 1; }
      100%    { transform: rotateX(90deg) translateZ(1px) scaleY(1) rotateZ(-360deg); opacity: 1; }
    }
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console