Text3D.vue 2.25 KB
Newer Older
hucy's avatar
hucy committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
<script setup lang="ts"></script>
<template>
  <div class="content fit center">
    <div class="container">
      <div class="text" style="--j: 0">
        <span style="--i: 0">2</span>
        <span style="--i: 1"></span>
        <span style="--i: 2">4</span>
        <span style="--i: 3">5</span>
      </div>
      <div class="text" style="--j: 1">
        <span style="--i: 0">0</span>
        <span style="--i: 1"></span>
        <span style="--i: 2">2</span>
        <span style="--i: 3">3</span>
      </div>
      <div class="text" style="--j: 2">
        <span style="--i: 0">2</span>
        <span style="--i: 1"></span>
        <span style="--i: 2">4</span>
        <span style="--i: 3">5</span>
      </div>
      <div class="text" style="--j: 3">
        <span style="--i: 0">2</span>
        <span style="--i: 1"></span>
        <span style="--i: 2">4</span>
        <span style="--i: 3">5</span>
      </div>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.content {
  background: #3d3d3d;
  font-family: 'Impact', sans-serif;
}
.container {
  display: flex;
  transform-style: preserve-3d;
  gap: 10px;
  transform: rotateY(30deg) rotateX(10deg);
  .text {
    position: relative;
    width: 100px;
    height: 100px;
    transform-style: preserve-3d;
    transition: 2.5s ease-in-out;
    transition-delay: calc(0.25s * var(--j));
    span {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: linear-gradient(#434343, #535353);
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 4em;
      color: #fff;
      transform-style: preserve-3d;
      transform: rotateX(calc(90deg * var(--i))) translateZ(50px);
    }
    &::before {
      content: '';
      position: absolute;
      width: 100%;
      height: 100%;
      background: #373737;
      transform-origin: left;
      transform: rotateY(90deg) translateX(-50px);
    }
    &:last-child {
      span {
        background: linear-gradient(#29c040, #32ed4e);
        color: #333;
      }
      &::before {
        background: #29ab3c;
      }
    }
  }
  &:hover {
    .text {
      transform: rotateX(-450deg);
      &:last-child {
        transform: rotateX(630deg);
      }
    }
  }
}
</style>