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

              
                #logo
  .box
    .side.front
    .side.left
    .side.back
    .side.right
    .side.bottom
    .flap.front
    .flap.back
    .flap.left
    .flap.right

              
            
!

CSS

              
                :root {
  --box-light: #f1b074;
  --box-mid: #a67549;
  --box-inner-mid: #9a673e;
  --box-dark: #8f5f37;
  --box-inner-dark: #7c4b26;
  --box-inner-darkest: #6b3e1c;
}

body {
  display: grid;
  place-items: center;
  height: 100vh;
  #logo {
    --size: 50vmin;
    width: var(--size);
    height: var(--size);
    padding: 1rem;
    background: #eee;
    border-radius: 0.5rem;
    perspective: 30rem;
    cursor: pointer;
    .box {
      position: relative;
      width: 100%;
      height: 100%;
      transform-style: preserve-3d;
      transform: translateZ(-20rem) rotatex(-15deg) rotatey(45deg);
      font-size: 2.5rem;
      text-align: center;
      transition: 0.75s;
      > * {
        position: absolute;
        background: #0008;
        transition: 0.5s;
      }
      .side {
        &.front,
        &.left,
        &.back,
        &.right {
          width: var(--size);
          height: calc(var(--size) * 0.75);
          transform:
            translateY(calc(var(--size) * 0.25))
            rotateY(var(--angle, 0deg))
            translateZ(calc(var(--size) * 0.499));
        }
        &.front {
          background: var(--box-mid);
        }
        &.right {
          --angle: 90deg;
          background: var(--box-inner-mid);
        }
        &.back {
          --angle: 180deg;
          background: var(--box-inner-dark);
        }
        &.left {
          --angle: -90deg;
          background: var(--box-dark);
        }
        &.bottom {
          width: var(--size);
          height: var(--size);
          transform:
            translateY(calc(var(--size) * 0.25))
            rotateX(90deg)
            translateZ(calc(var(--size) * -0.249));
          background: var(--box-inner-darkest);
          /*&:before {
            content:"Hi, I'm back!";
            color:white;
            font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
            font-size: 6vmin;
          }*/
        }
      }
      .flap {
        background: var(--box-light);
        &.front,
        &.back {
          width: var(--size);
          height: calc(var(--size) * 0.5);
        }
        &.left,
        &.right {
          width: calc(var(--size) * 0.5);
          height: var(--size);
        }
        &.front {
          transform-origin: 50% 100% calc(var(--size) * 0.5);
          //These transform-origins were a pain to find, front and back I found to be easier because they didn't require an aditional rotation to account for
          transform:
            translateY(calc(var(--size) * -0.25))
            rotateX(90deg)
            translateZ(calc(var(--size) * 0.499));
        }
        &.back {
          transform-origin: 50% 100% calc(var(--size) * -0.5);
          transform:
            translateY(calc(var(--size) * -0.25))
            rotateX(-90deg)
            translateZ(calc(var(--size) * -0.499));
        }
        &.left {
          transform-origin: 0 50% 0;
          transform:
            translateY(calc(var(--size) * -0.25))
            rotateX(90deg)
            rotateY(0deg);
        }
        &.right {
          transform-origin: 0 50% 0;
          transform:
            translateX(var(--size))
              //This is a duplication of left but translated over and reversed because the transform-origin didn't play nicely with this configuration
              //hence the same transform-origin. I would love to see how someone else would have solved this but I spent too long trying to get a nicer solution.
            translateY(calc(var(--size) * -0.25))
            rotateX(90deg)
            rotateY(180deg);
        }
      }
    }
    $transitiondelay: 0.2s; //CSS variable here is pointless as the animation is baked, it's just the value appears multiple times
    &:not(:hover) {
      .box {
        .flap {
          &.left,
          &.right {
            transition-delay: $transitiondelay;
          }
        }
      }
    }
    &:hover {
      .box {
        transform: translateZ(-30rem) rotatex(-40deg) rotatey(15deg);
        .flap {
          //The only difference is that the main axis of rotation is 210degrees outwards (the value that isn't a multiple of 90 is the one that was changed)
          background: var(--box-inner-mid);
          &.front,
          &.back {
            transition-delay: $transitiondelay;
          }
          &.front {
            transform:
              translateY(calc(var(--size) * -0.25))
              rotateX(-120deg) //< changed
              translateZ(calc(var(--size) * 0.499));
          }
          &.back {
            transform:
              translateY(calc(var(--size) * -0.25))
              rotateX(120deg) //< changed
              translateZ(calc(var(--size) * -0.499));
          }
          &.left {
            transform:
              translateY(calc(var(--size) * -0.25))
              rotateX(90deg)
              rotateY(-210deg); //< changed
          }
          &.right {
            transform:
              translateX(var(--size))
              translateY(calc(var(--size) * -0.25))
              rotateX(90deg)
              rotateY(380deg); //< changed
          }
        }
      }
    }
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console