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>
相关推荐
i_am_a_div_日积月累_2 分钟前
前端路由缓存实现
前端·javascript·vue.js
咪库咪库咪20 分钟前
异步js和http请求
前端
厨猿加加20 分钟前
FlatList 在 React Native 的最佳实践
前端·react native
用户28800074867421 分钟前
前端连接VNC(无需后端)的完整教程
前端
郝某人一生平安21 分钟前
前端 Word 模板参入特定数据 并且下载
前端·vue.js
jaffees23 分钟前
自定义多级联动选择器(uni-app)
前端
_一条咸鱼_23 分钟前
深入剖析 Vue 过滤器模块(十三)
前端·javascript·面试
独立开阀者_FwtCoder25 分钟前
一口气讲清楚:LLM、MCP、EMB
前端·javascript·人工智能
蔓越莓27 分钟前
JS实现css响应式布局方案
前端
林夕112027 分钟前
Node.js Web开发进阶:Stream、HTTP模块与文件上传全解析
前端·node.js·全栈