CSS3心跳和小球跳动animation案例

javascript 复制代码
<script setup>
import { ref, onMounted, onUnmounted, nextTick, watch, reactive } from 'vue'

onMounted(() => {
})
onUnmounted(() => {
});



</script>

<template>
  <div style="display: flex;">
    <div class="heart">
    </div>
    <div class="info">
      <div class="ball">
      </div>
      <div class="bottom"></div>
    </div>
  </div>


</template>

<style scoped lang="less">
.info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100vh;
  height: 100vh;
}

.heart {
  width: 100px;
  height: 100px;
  background-color: red;
  margin: 200px auto;
  transform: rotate(45deg) scale(.5);
  opacity: .5;
  // animation: hd 4s infinite;
  animation-name: hd;
  animation-duration: 2s;
  animation-iteration-count: infinite;

  &::before {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: red;
    transform: translateX(-50px);
  }

  &::after {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: red;
    transform: translateY(-50px);
  }
}

@keyframes hd {
  25% {
    transform: rotate(45deg) scale(1);
    opacity: 1;
  }

  50% {
    transform: rotate(45deg) scale(.5);
    opacity: .5;
  }

  75% {
    transform: rotate(45deg) scale(1);
    opacity: 1;
  }

  85% {
    transform: rotate(45deg) scale(.5);
    opacity: .5;
  }

  to {
    transform: rotate(45deg) scale(1);
    opacity: 1;
  }
}

.ball {
  width: 100px;
  height: 100px;
  // 渐变色
  background: radial-gradient(at center, #e67e22, #e74c3c); // 渐变色
  border-radius: 50%;
  border-radius: 50%;
  // margin: 300px 50px;
  animation: ball 1s infinite reverse;
}

.bottom {
  width: 300px;
  height: 40px;
  background-color: rgba(0, 0, 0, .3);
  border-radius: 50%;
  z-index: -1;
  filter: blur(5px);
  animation: shadow 1s infinite reverse;
}

@keyframes ball {
  to {
    transform: translateY(-200px);
  }
}

@keyframes shadow {
  to {
    width: 300px;
    height: 20px;
    background-color: rgba(0, 0, 0, .1);
    border-radius: 50%;
    filter: blur(35px);
  }
}
</style>
相关推荐
前端 贾公子1 小时前
v-if 与 v-for 的优先级对比
开发语言·前端·javascript
bug总结5 小时前
Vue3 实现后台管理系统跳转大屏自动登录功能
前端·javascript·vue.js
用户47949283569155 小时前
同事一个比喻,让我搞懂了Docker和k8s的核心概念
前端·后端
烛阴5 小时前
C# 正则表达式(5):前瞻/后顾(Lookaround)——零宽断言做“条件校验”和“精确提取”
前端·正则表达式·c#
C_心欲无痕5 小时前
浏览器缓存: IndexDB
前端·数据库·缓存·oracle
郑州光合科技余经理5 小时前
技术架构:上门服务APP海外版源码部署
java·大数据·开发语言·前端·架构·uni-app·php
GIS之路6 小时前
GDAL 实现数据属性查询
前端
PBitW7 小时前
2025,菜鸟的「Vibe Coding」时刻
前端·年终总结
mwq301237 小时前
不再混淆:导数 (Derivative) 与微分 (Differential) 的本质对决
前端
小二·8 小时前
Vue 3 组件通信全方案详解:Props/Emit、provide/inject、事件总线替代与组合式函数封装
前端·javascript·vue.js