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>
相关推荐
sTone873753 小时前
Chrome devtools二次开发准备:获取源码和编译
前端·google
龙泉寺天下行走3 小时前
[Powershell入门教程]第4天:模块、脚本编写、错误处理与 .NET 集成
java·服务器·前端
晴天丨4 小时前
Vite:下一代前端构建工具深度解析与实践指南
前端
多来哈米4 小时前
Jenkins配置vue前端项目(最简单的操作)
运维·前端·jenkins
一只叁木Meow4 小时前
Vue scoped CSS 与 Element Plus Drawer 样式失效问题深度解析
前端
用户92426257007314 小时前
Vue 学习笔记:组件通信(Props / 自定义事件)与插槽(Slot)全解析
前端
UIUV4 小时前
Ajax 数据请求学习笔记
前端·javascript·代码规范
FogLetter4 小时前
手写useInterval:告别闭包陷阱,玩转React定时器!
前端·react.js
神秘的猪头4 小时前
Vibe Coding 实战教学:用 Trae 协作开发 Chrome 扩展 “Hulk”
前端·人工智能
小时前端4 小时前
当递归引爆调用栈:你的前端应用还能优雅降落吗?
前端·javascript·面试