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

              
                  <div class="container">
    <div class="companion-cube">

    <div class="cube-face front">
      <div class="h-line"></div>
      <div class="v-line"></div>
      <div class="circle">
        <div class="heart-container">
          <div class="base"></div>
        </div>
      </div>

      <div class="extracube">
        <div class="left group">
          <div class="corner piece top"></div>
          <div class="center piece left"></div>
          <div class="corner piece bottom"></div>
          <div class="center piece bottom"></div>
        </div>
        <div class="right group">
          <div class="corner piece top"></div>
          <div class="center piece left"></div>
          <div class="corner piece bottom"></div>
          <div class="center piece bottom"></div>
        </div>
      </div>
    </div>

    <div class="cube-face back">
      <div class="h-line"></div>
      <div class="v-line"></div>
      <div class="circle">
        <div class="heart-container">
          <div class="base"></div>
        </div>
      </div>
      <div class="extracube">
        <div class="left group">
          <div class="corner piece top"></div>
          <div class="center piece left"></div>
          <div class="corner piece bottom"></div>
          <div class="center piece bottom"></div>
        </div>
        <div class="right group">
          <div class="corner piece top"></div>
          <div class="center piece left"></div>
          <div class="corner piece bottom"></div>
          <div class="center piece bottom"></div>
        </div>
      </div>
    </div>

    <div class="cube-face top">
      <div class="h-line"></div>
      <div class="v-line"></div>
      <div class="circle">
        <div class="heart-container">
          <div class="base"></div>
        </div>
      </div>
      <div class="extracube">
        <div class="left group">
          <div class="corner piece top"></div>
          <div class="center piece left"></div>
          <div class="corner piece bottom"></div>
          <div class="center piece bottom"></div>
        </div>
        <div class="right group">
          <div class="corner piece top"></div>
          <div class="center piece left"></div>
          <div class="corner piece bottom"></div>
          <div class="center piece bottom"></div>
        </div>
      </div>
    </div>

    <div class="cube-face bottom">
      <div class="h-line"></div>
      <div class="v-line"></div>
      <div class="circle">
        <div class="heart-container">
          <div class="base"></div>
        </div>
      </div>
      <div class="extracube">
        <div class="left group">
          <div class="corner piece top"></div>
          <div class="center piece left"></div>
          <div class="corner piece bottom"></div>
          <div class="center piece bottom"></div>
        </div>
        <div class="right group">
          <div class="corner piece top"></div>
          <div class="center piece left"></div>
          <div class="corner piece bottom"></div>
          <div class="center piece bottom"></div>
        </div>
      </div>
    </div>

    <div class="cube-face left">
      <div class="h-line"></div>
      <div class="v-line"></div>
      <div class="circle">
        <div class="heart-container">
          <div class="base"></div>
        </div>
      </div>
      <div class="extracube">
        <div class="left group">
          <div class="corner piece top"></div>
          <div class="center piece left"></div>
          <div class="corner piece bottom"></div>
          <div class="center piece bottom"></div>
        </div>
        <div class="right group">
          <div class="corner piece top"></div>
          <div class="center piece left"></div>
          <div class="corner piece bottom"></div>
          <div class="center piece bottom"></div>
        </div>
      </div>
    </div>

    <div class="cube-face right">
      <div class="h-line"></div>
      <div class="v-line"></div>
      <div class="circle">
        <div class="heart-container">
          <div class="base"></div>
        </div>
      </div>

      <div class="extracube">
        <div class="left group">
          <div class="corner piece top"></div>
          <div class="center piece left"></div>
          <div class="corner piece bottom"></div>
          <div class="center piece bottom"></div>
        </div>
        <div class="right group">
          <div class="corner piece top"></div>
          <div class="center piece left"></div>
          <div class="corner piece bottom"></div>
          <div class="center piece bottom"></div>
        </div>
      </div>

    </div>

    </div>

    <div class="floor-container">
      <div class="floor"></div>
      <div class="wall"></div>
    </div>
  </div>

<div class="created">
  <span>Created by</span>
  <a href="https://manz.dev/"><h2>Manz.dev</h2></a>
  <p>on <a href="https://twitch.tv/ManzDev">Twitch</a> / <a href="https://youtube.com/c/ManzDev">Youtube</a></p>
</div>
              
            
!

CSS

              
                @use postcss-nested;

:root {
  --cube-size: 300px;
  --pink-cube-color: #f76488;
  --grey-cube-color: #e7e6e4;
  --core-cube-color: #7a7a7a;
  --heart-color: #feaec9;
  --piece-color: #999;
  --piece-light: #aaa;
}

body {
  margin: 13em 0;
  background: #2d2f31;
  overflow: hidden;
}

.container {
  display: flex;
  justify-content: center;
  align-items: center;
}

.companion-cube {
  width: var(--cube-size);
  height: var(--cube-size);
  position: relative;
  backface-visibility: hidden;
  transform-style: preserve-3d;
  animation: walkCube 6s linear infinite;
}

.cube-face {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  background: #666d;
  box-shadow: 0 0 10px #0005 inset;

  & .extracube {
    width: 100%;
    height: 100%;
    position: absolute;
    transform: translateZ(10px);
  }

  & .piece {
    --piece-size: 38%;

    z-index: 5;
    position: absolute;

    &.corner {
      width: var(--piece-size);
      height: var(--piece-size);
      top: 0;
      left: 0;
      background: radial-gradient(at 115% 115%, transparent 27%, var(--piece-light) 30% 39%, var(--piece-color) 40%);
      box-shadow:
        0 0 10px #4448 inset,
        14px 14px 20px #ddd inset;
    }

    &.center {
      width: 15%;
      height: 15%;
      background-color: var(--piece-color);
      background-image: radial-gradient(ellipse 50% 200% at 90%, var(--piece-light) 30%, transparent 32%);
      top: 42%;
      left: 0;
      box-shadow:
        0 0 10px #4448 inset,
        14px 0 10px #ddd inset;
    }

    &.corner.bottom {
      transform: scaleY(-1);
      top: auto;
      bottom: 0;
    }

    &.center.bottom {
      transform: rotate(-90deg);
      top: auto;
      bottom: 0;
      left: 42.5%;
    }
  }

  & .group {
    position: absolute;

    &.left {
      width: 100%;
      height: 100%;
    }

    &.right {
      position: absolute;
      width: 100%;
      height: 100%;
      transform: rotate(180deg);
      z-index: 10;
    }
  }

  /* 3D */
  &.front {
    z-index: 1;
  }

  &.top {
    transform-origin: 50% 100%;
    transform: translateY(calc(-1 * var(--cube-size))) rotateX(90deg);
  }

  &.right {
    transform-origin: 0% 50%;
    transform: translateX(var(--cube-size)) rotateY(90deg);
  }

  &.left {
    transform-origin: 100% 50%;
    transform: translateX(calc(-1 * var(--cube-size))) rotateY(-90deg);
  }

  &.bottom {
    transform-origin: 50% 0%;
    transform: translateY(var(--cube-size)) rotateX(-90deg);
  }

  &.back {
    transform: translateZ(calc(-1 * var(--cube-size))) rotateY(180deg);
  }

  & .circle {
    width: 40%;
    height: 40%;
    background: var(--grey-cube-color);
    background: radial-gradient(#fff, #cccc);
    border: 6px solid #b3b3b3;
    border-bottom: 0;
    border-right: 0;
    border-radius: 50%;
    position: relative;
    z-index: 5;
    display: grid;
    place-items: center;

    & .heart-container {
      width: 75%;
      height: 75%;
      display: flex;
      position: relative;
      justify-content: center;
      filter: drop-shadow(0 0 4px #fff);

      & .base {
        width: 55%;
        height: 55%;
        background: var(--heart-color);
        position: absolute;
        bottom: 15%;
        transform: rotate(-45deg);
        border-radius: 5% 90% 100% 0% / 100% 90% 5% 0%;
      }

      &::before,
      &::after {
        content: "";
        width: 45%;
        height: 45%;
        border-radius: 50%;
        display: block;
        background: var(--heart-color);
        position: absolute;
        transform: translate(calc(50% * var(--direction, 1)), 35%);
      }

      &::before { --direction: -1; }
    }
  }

  & .h-line,
  & .v-line {
    width: 5%;
    height: 100%;
    background: var(--pink-cube-color);
    border-left: 1px solid #ff96bd;
    border-right: 1px solid #964160;
    position: absolute;
  }

  & .v-line {
    transform: rotate(90deg);
  }
}

@keyframes walkCube {
  0% { transform: rotateX(0deg) rotateY(0deg) rotateZ(0); }
  100% { transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg); }
}

.floor-container {
  width: 200vw;
  height: 100vh;
  position: absolute;
  top: 0;
  left: -50%;
  z-index: -5;
  display: flex;
  flex-wrap: wrap;
  perspective: 400px;

  & .floor {
    width: 100%;
    height: 50%;
    background-image:
      repeating-linear-gradient(
        to bottom,
        transparent 0 200px,
        #333 200px 202px
      ),
      repeating-linear-gradient(
        to right,
        #e1e8e5 0 100px,
        #333 100px 102px
      );
    position: absolute;
    bottom: 0;
    transform: rotateX(45deg);
  }

  & .wall {
    width: 100%;
    height: 100%;
    background-image:
      repeating-linear-gradient(
        to bottom,
        transparent 0 200px,
        #aaa 200px 202px
      ),
      repeating-linear-gradient(
        to right,
        #2d3237 0 100px,
        #aaa 100px 102px
      );
    position: absolute;
    z-index: -2;
  }
}


.created {
  background: 
    url(https://assets.codepen.io/154065/internal/avatars/users/default.png),
    linear-gradient(to bottom, #884ced, #ec1cce);
  background-size: 75px 75px, cover;
  background-repeat: no-repeat;
  position: absolute;
  top: 0;
  right: 0;
  width: 250px;
  height: 75px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-left: 2em;
  
  & span,
  & h2,
  & p,
  & a {
    font-family: Montserrat;
    margin: 0;
  }
  
  & a,
  & p,
  & span {
    color: #fff;    
  }
  
  & h2 {
    font-weight: 700;
    transform: translate(0, -4px);    
  }
  
  & a {
    text-decoration-color: rgba(255,255,255,0.4);
  }
  
  & a:hover {
    color: #e6e82a;
  }
}
              
            
!

JS

              
                /* Look mom, without JS */
              
            
!
999px

Console