css实现心跳图

做个小demo,熟悉一下transform和animation属性,心心图,看效果先~在这里插入图片描述
实现代码如下:

  1. html代码
  <div class="heartbeat">
    <ul>
      <li class="list1"></li>
      <li class="list2"></li>
      <li class="list3"></li>
      <li class="list4"></li>
      <li class="list5"></li>
      <li class="list6"></li>
      <li class="list7"></li>
      <li class="list8"></li>
      <li class="list9"></li>
    </ul>
  </div>

  1. css代码
    .heartbeat {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;  /* vh是相对视口单位 100vh=100% * 视口高度*/
      background-color: #82589F;
    }
    ul {
      list-style: none;
    }
    ul>li {
      float: left;
      width: 20px;
      height: 20px;
      border-radius: 10px;
      margin-right: 20px;
    }
    .list1 {
      background-color: #FEA47F;
      animation: heart1 4s infinite;
    }
    .list2 {
      background-color: #25CCF7;
      animation: heart2 4s infinite 0.15s;
    }
    .list3 {
      background-color: #EAB543;
      animation: heart3 4s infinite 0.3s;
    }
    .list4 {
      background-color: #58B19F;
      animation: heart4 4s infinite 0.45s;
    }
    .list5 {
      background-color: #FD7272;
      animation: heart5 4s infinite 0.6s;
    }
    .list6 {
      background-color: #55E6C1;
      animation: heart4 4s infinite 0.75s;
    }
    .list7 {
      background-color: #F8EFBA;
      animation: heart3 4s infinite 0.9s;
    }
    .list8 {
      background-color: #1B9CFC;
      animation: heart2 4s infinite 1.05s;
    }
    .list9 {
      background-color: #F97F51;
      animation: heart1 4s infinite 1.2s;
    }
 
   @keyframes heart1 {
     25%,
     50% {
       height: 60px;
       transform: translateY(-30px);
     }
     75%,
     100% {
       height: 20px;
       transform: translateY(0px);
     }
   }
   @keyframes heart2 {
     25%,
     50% {
       height: 125px;
       transform: translateY(-60px);
     }
     75%,
     100% {
       height: 20px;
       transform: translateY(0px);
     }
   }
   @keyframes heart3 {
     25%,
     50% {
       height: 160px;
       transform: translateY(-70px);
     }
     75%,
     100% {
       height: 20px;
       transform: translateY(0px);
     }
   }
   @keyframes heart4 {
     25%,
     50% {
       height: 180px;
       transform: translateY(-50px);
     }
     75%,
     100% {
       height: 20px;
       transform: translateY(0px);
     }
   }
   @keyframes heart5 {
     25%,
     50% {
       height: 190px;
       transform: translateY(-30px);
     }
     75%,
     100% {
       height: 20px;
       transform: translateY(0px);
     }
   }

啦啦啦,其实就是这样啦,用动画的延时还有translate就可以实现这样一个好看的心心图。

在这里插入图片描述

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值