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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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="camera">
  <div class="board">
    <div class="cube">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube cube-12">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube cube-1">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top">
        <div class="clip clip-1"><span class="char-1">大</span></div>
      </div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube cube-2">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top">
        <div class="clip clip-2"><span class="char-1">大</span></div>
      </div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube cube-11">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube cube-3">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top">
        <div class="clip clip-3"><span class="char-1">大</span><span class="char-2">前</span></div>
      </div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube cube-4">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top">
        <div class="clip clip-4"><span class="char-1">大</span><span class="char-2">前</span></div>
      </div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube cube-13">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube cube-10">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube cube-5">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top">
        <div class="clip clip-5"><span class="char-2">前</span><span class="char-3">端</span></div>
      </div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube cube-6">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top">
        <div class="clip clip-6"><span class="char-2">前</span><span class="char-3">端</span></div>
      </div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube cube-14">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube cube-9">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube cube-7">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top">
        <div class="clip clip-7"><span class="char-3">端</span></div>
      </div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube cube-8">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top">
        <div class="clip clip-8"><span class="char-3">端</span></div>
      </div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube invisible">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
    <div class="cube">
      <div class="face cube__front"></div>
      <div class="face cube__back"></div>
      <div class="face cube__right"></div>
      <div class="face cube__left"></div>
      <div class="face cube__top"></div>
      <div class="face cube__bottom"></div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  background: var(--grey-color-4);
}

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

:root {
  --red-color: #ae2a4a;
  --grey-color-1: #979797;
  --grey-color-2: #959595;
  --grey-color-3: #e0dfe0;
  --grey-color-4: #dadada;
}

@mixin cube($width, $height, $depth) {
  &__front {
    @include cube-front($width, $height, $depth);
  }
  &__back {
    @include cube-back($width, $height, $depth);
  }
  &__right {
    @include cube-right($width, $height, $depth);
  }
  &__left {
    @include cube-left($width, $height, $depth);
  }
  &__top {
    @include cube-top($width, $height, $depth);
  }
  &__bottom {
    @include cube-bottom($width, $height, $depth);
  }
  .face {
    position: absolute;
    border-radius: 4px;
  }
}

@mixin cube-front($width, $height, $depth) {
  width: var($width);
  height: var($height);
  transform-origin: bottom left;
  transform: rotateX(-90deg)
    translateZ(calc(calc(var(#{$depth}) * 2) - var(#{$height})));
}

@mixin cube-back($width, $height, $depth) {
  width: var($width);
  height: var($height);
  transform-origin: top left;
  transform: rotateX(-90deg) rotateY(180deg)
    translateX(calc(var(#{$width}) * -1)) translateY(calc(var(#{$height}) * -1));
}

@mixin cube-right($width, $height, $depth) {
  width: calc(var(#{$depth}) * 2);
  height: var($height);
  transform-origin: top left;
  transform: rotateY(90deg) rotateZ(-90deg) translateZ(var(#{$width}))
    translateX(calc(var(#{$depth}) * -2)) translateY(calc(var(#{$height}) * -1));
}

@mixin cube-left($width, $height, $depth) {
  width: calc(var(#{$depth}) * 2);
  height: var($height);
  transform-origin: top left;
  transform: rotateY(-90deg) rotateZ(90deg)
    translateY(calc(var(#{$height}) * -1));
}

@mixin cube-top($width, $height, $depth) {
  width: var($width);
  height: calc(var(#{$depth}) * 2);
  transform-origin: top left;
  transform: translateZ(var($height));
}

@mixin cube-bottom($width, $height, $depth) {
  width: var($width);
  height: calc(var(#{$depth}) * 2);
  transform-origin: top left;
  transform: rotateY(180deg) translateX(calc(var(#{$width}) * -1));
}

.cube {
  --cube-width: 3rem;
  --cube-height: 1rem;
  --cube-depth: 1.5rem;

  @include cube(--cube-width, --cube-height, --cube-depth);
  width: 3rem;
  height: 1rem;

  &__front {
    background-color: var(--grey-color-1);
  }
  &__back {
    background-color: var(--grey-color-3);
  }
  &__right {
    background-color: var(--grey-color-1);
  }
  &__left {
    background-color: var(--grey-color-2);
  }
  &__top {
    background-color: var(--grey-color-3);
    overflow: hidden;
  }
  &__bottom {
    background-color: var(--grey-color-2);
  }
}

.camera {
  perspective: 300px;
  transform: scale(3);
}

.board {
  --board-row: 4;
  --board-col: 6;
  position: relative;
  display: grid;
  grid-template-rows: repeat(var(--board-row), 1fr);
  grid-template-columns: repeat(var(--board-col), 1fr);
  width: 18rem;
  height: 12rem;
  transform: rotateX(45deg);
}

.clip {
  position: relative;
  display: flex;
  flex-direction: column;
  font-size: 4rem;
  line-height: 1;
  color: var(--red-color);
  user-select: none;

  &-1 {
    text-align: right;
    left: 38%;
  }

  &-2 {
    right: 61%;
  }

  &-3 {
    text-align: right;
    left: 38%;
    bottom: 100%;
  }

  &-4 {
    right: 61%;
    bottom: 100%;
  }

  &-5 {
    text-align: right;
    left: 38%;
    bottom: 68%;
  }

  &-6 {
    right: 61%;
    bottom: 68%;
  }

  &-7 {
    text-align: right;
    left: 38%;
    bottom: 35%;
  }

  &-8 {
    right: 61%;
    bottom: 35%;
  }
}

              
            
!

JS

              
                const text = "大前端";
const chars = text.split("");
const char1 = document.querySelectorAll(".char-1");
const char2 = document.querySelectorAll(".char-2");
const char3 = document.querySelectorAll(".char-3");
char1.forEach((e) => (e.textContent = chars[0]));
char2.forEach((e) => (e.textContent = chars[1]));
char3.forEach((e) => (e.textContent = chars[2]));
const cube1 = ".cube-1";
const cube2 = ".cube-2";
const cube3 = ".cube-3";
const cube4 = ".cube-4";
const cube5 = ".cube-5";
const cube6 = ".cube-6";
const cube7 = ".cube-7";
const cube8 = ".cube-8";
const cube9 = ".cube-9";
const cube10 = ".cube-10";
const cube11 = ".cube-11";
const cube12 = ".cube-12";
const cube13 = ".cube-13";
const cube14 = ".cube-14";
const xForwards = "100%";
const xBackwards = "-100%";
const yForwards = "300%";
const yBackwards = "-300%";
const t1 = gsap.timeline({
  defaults: {
    duration: 0.4,
    ease: "power2.in",
  },
});
// 8x1 6y1 5x1 7y-1 9x1 10y1 7x-1 3y1 11x1 12y1 1x-1 11y-1 4x-1 13x-1 14|8y-1
t1.to(cube8, { x: xForwards })
  .to(cube6, { y: yForwards })
  .to(cube5, { x: xForwards })
  .to(cube7, { y: yBackwards })
  .to(cube9, { x: xForwards })
  .to(cube10, { y: yForwards })
  .to(cube7, { x: xBackwards })
  .to(cube3, { y: yForwards })
  .to(cube11, { x: xForwards })
  .to(cube12, { y: yForwards })
  .to(cube1, { x: xBackwards })
  .to(cube11, { y: yBackwards })
  .to(cube4, { x: xBackwards })
  .to(cube13, { x: xBackwards })
  .to([cube14, cube8], { y: yBackwards });
t1.reverse(0);

              
            
!
999px

Console