Hi FE !
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
  • C009-加载效果吃豆豆

C009-加载效果吃豆豆

<template>
  <div class="pacManBox">
    <div class="pacMan">
      <div class="eye"></div>
      <div class="mouth1"></div>
      <div class="mouth2"></div>
      <div class="beanOne"></div>
      <div class="beanTwo"></div>
    </div>
    <div class="pacManBoxText threedtext">敬请期待</div>
  </div>
</template>

<script setup lang="ts"></script>
<style scoped lang="scss">
.threedtext {
  text-align: center;
  width: none;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: hsl(30, 91%, 50%);
  text-shadow: 1px 1px 0px hsl(30, 68%, 62%), 1px 2px 0px hsl(30, 68%, 62%),
    1px 3px 0px hsl(30, 68%, 62%), 1px 4px 0px hsl(30, 68%, 62%),
    1px 5px 0px hsl(30, 68%, 62%), 1px 6px 0px hsl(30, 68%, 62%),
    1px 10px 5px rgba(139, 139, 139, 0.5), 1px 15px 10px rgba(16, 16, 16, 0.4),
    1px 20px 30px rgba(139, 139, 139, 0.5), 1px 25px 50px rgba(16, 16, 16, 0.2);
}
.pacManBoxText {
  margin-top: 120px;
}
.pacManBox {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pacMan {
  display: block;
  position: relative;
  margin-top: 20px;
  translate: 50px;
}

/* 使用伪元素创建吃豆人的眼睛 */
.pacMan::before {
  content: "";
  width: 0.4em;
  height: 0.4em;
  border-radius: 50%;
  background-color: #333;
  position: absolute;
  top: 6px;
  left: 21px;
  z-index: 2000;
}

/* mouth1搭配mouth2组成吃豆人张嘴闭嘴的动画 */
.mouth1 {
  width: 0;
  height: 0;
  border: 25px solid #e1b204;
  border-radius: 50%;
  border-right-color: transparent;
  animation: upup 0.32s 0s infinite;
  position: relative;
  z-index: 3;
}

@keyframes upup {
  0% {
    transform: rotate(270deg);
  }

  50% {
    transform: rotate(1turn);
  }

  100% {
    transform: rotate(270deg);
  }
}

.mouth2 {
  width: 0;
  height: 0;
  border: 25px solid #e1b204;
  border-right-color: transparent;
  border-radius: 25px;
  margin-top: -50px;
  animation: downdown 0.32s 0s infinite;
  position: relative;
  z-index: 3;
}

@keyframes downdown {
  0% {
    transform: rotate(90deg);
  }

  50% {
    transform: rotate(0);
  }

  100% {
    transform: rotate(90deg);
  }
}

/* 豆子不断移动 */
.beanOne {
  background-color: #e1b204;
  border-radius: 50%;
  width: 10px;
  height: 10px;
  position: absolute;
  transform: translateY(-6px);
  top: 25px;
  left: 100px;
  animation: beanAnimation 1s linear 0.52s infinite;
}

.beanTwo {
  background-color: #e1b204;
  border-radius: 50%;
  width: 10px;
  height: 10px;
  position: absolute;
  transform: translateY(-6px);
  top: 25px;
  left: 100px;
  animation: beanAnimation 1s linear 1.1s infinite;
}

@keyframes beanAnimation {
  75% {
    opacity: 0.72;
  }

  100% {
    transform: translate(-100px, -6px);
  }
}
</style>

Edit this page
最近更新: 2025/12/2 01:46
Contributors: qdleader
qdleader
本站总访问量 129823次 | 本站访客数 12人