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>
相关推荐
莹雨潇潇3 分钟前
Docker 快速入门(Ubuntu版)
java·前端·docker·容器
Jiaberrr11 分钟前
Element UI教程:如何将Radio单选框的圆框改为方框
前端·javascript·vue.js·ui·elementui
Tiffany_Ho1 小时前
【TypeScript】知识点梳理(三)
前端·typescript
安冬的码畜日常2 小时前
【D3.js in Action 3 精译_029】3.5 给 D3 条形图加注图表标签(上)
开发语言·前端·javascript·信息可视化·数据可视化·d3.js
太阳花ˉ2 小时前
html+css+js实现step进度条效果
javascript·css·html
小白学习日记3 小时前
【复习】HTML常用标签<table>
前端·html
丁总学Java3 小时前
微信小程序-npm支持-如何使用npm包
前端·微信小程序·npm·node.js
yanlele3 小时前
前瞻 - 盘点 ES2025 已经定稿的语法规范
前端·javascript·代码规范
懒羊羊大王呀3 小时前
CSS——属性值计算
前端·css