css3绘制黑色可爱的小猫咪和爱心图形动画特效

这个是用css3绘制黑色可爱的小猫咪,如果喜欢的你们可以试一下哦~
在这里插入图片描述

html代码

<body>
<div class="container">
  <div class="cat">
    <div class="face">
      <div class="ear-left">
        <div class="inner-l"></div>
      </div>
      <div class="ear-right">
        <div class="inner-r"></div>
      </div>
      <div class="eye-left">
        <div class="eye-ball">
          <div class="eye-light"></div>
          <div class="shadow-light"></div>
        </div>
      </div>
      <div class="eye-right">
        <div class="eye-ball">
          <div class="eye-light"></div>
          <div class="shadow-light"></div>
        </div>
      </div>
      <div class="nose">
        <div class="l1"></div>
        <div class="l2"></div>
      </div>
    </div>
    <div class="cat-body">
      <div class="paw1"></div>
      <div class="paw2"></div>
      <div class="tail"></div>
    </div>
  </div>
  <div class="heart">
    <div class="heart-l"></div>
    <div class="heart-r"></div>
  </div>
</div>
</body>

css代码

:root {
  --bg-color: #ffcccc;
  --fur: #33292b;
  --inner-ear: #d36149;
  --eye: #ddb54d;
  --eyeball: #030303;
  --eyelight: #fafafa;
  --nose: #d3918e;
  --heart: #dc4053;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow:hidden;
}

body {
  box-sizing: border-box;
  background-color: var(--bg-color);
}

.container {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.cat {
  position: relative;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.face {
  background-color: var(--fur);
  width: 200px;
  height: 164px;
  border-radius: 50%;
  position: absolute;
}

.ear-left,
.ear-right {
  width: 0;
  height: 0;
  border-bottom: 60px solid var(--fur);
  border-left: 42px solid transparent;
  border-right: 42px solid transparent;
  position: relative;
}

.ear-left {
  bottom: 30px;
  transform: rotate(-35deg);
  animation-name: an-ears;
  animation-duration: 1.5s;
  animation-iteration-count: infinite;
  animation-direction: alternate-reverse;
}

@keyframes an-ears {
  from {
    top: -15px;
  }
  to {
    top: -30px;
  }
}

@keyframes ear-dance-right {
  from {
    top: -75px;
  }
  to {
    top: -88px;
  }
}

.ear-right {
  bottom: 90px;
  left: 125px;
  transform: rotate(35deg);
  animation-name: ear-dance-right;
  animation-duration: 1.5s;
  animation-iteration-count: infinite;
  animation-direction: alternate-reverse;
}

.inner-l {
  width: 0;
  height: 0;
  right: 27px;
  border-bottom: 45px solid var(--inner-ear);
  border-left: 27px solid transparent;
  position: relative;
}

.inner-r {
  width: 0;
  height: 0;
  border-bottom: 45px solid var(--inner-ear);
  border-right: 27px solid transparent;
  position: relative;
}

.eye-left,
.eye-right {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--eye);
  position: relative;
}

.eye-left {
  bottom: 65px;
  left: 45px;
}

.eye-right {
  bottom: 105px;
  left: 125px;
}

.eye-ball {
  width: 30px;
  height: 30px;
  background-color: var(--eyeball);
  position: relative;
  border-radius: 50%;
  top: 4px;
  left: 5px;
}

.eye-light {
  width: 5px;
  height: 5px;
  background-color: var(--eyelight);
  position: relative;
  border-radius: 50%;
  top: 8px;
  left: 12px;
}

.shadow-light {
  width: 7px;
  height: 7px;
  background-color: #fefefe;
  position: relative;
  border-radius: 50%;
  top: -2px;
  left: 20px;
}

.nose {
  width: 20px;
  height: 18px;
  background-color: var(--nose);
  border-radius: 49% 51% 50% 50% / 10% 10% 90% 90%;
  position: relative;
  bottom: 103px;
  left: 96px;
}

.l1,
.l2 {
  background-color: var(--nose);
  height: 16px;
  width: 1px;
  position: relative;
}

.l1 {
  transform: rotate(45deg);
  left: 4px;
  top: 14px;
}

.l2 {
  transform: rotate(-45deg);
  left: 14px;
  top: -2px;
}

.cat-body {
  background-color: var(--fur);
  width: 210px;
  height: 200px;
  position: relative;
  top: 146px;
  left: 40px;
  border-radius: 25% 80% 100% 0% / 25% 100% 0% 100%;
}

.paw1,
.paw2 {
  background-color: var(--fur);
  height: 22px;
  width: 33px;
  position: relative;
  top: 198px;
  border-radius: 0% 100% 49% 51% / 0% 0% 100% 100%;
}

.paw2 {
  top: 177px;
  left: 60px;
}

.tail {
  background-color: var(--fur);
  width: 168px;
  height: 25px;
  position: relative;
  top: 96px;
  left: 197px;
  border-radius: 0 20px 20px 0;
  transform: rotate(-25deg);
}

.heart {
  background-color: var(--heart);
  height: 100px;
  width: 100px;
  bottom: 250px;
  left: 250px;
  position: absolute;
  transform: rotate(45deg);
  animation: beat 2s infinite;
}

.heart-l,
.heart-r {
  background-color: var(--heart);
  height: 70px;
  width: 100px;
  position: relative;
  border-radius: 150px 150px 0 0;
}

.heart-l {
  bottom: 45px;
  position: relative;
}

.heart-r {
  bottom: 55px;
  right: 60px;
  transform: rotate(-90deg);
}

@keyframes beat {
  0% {
    transform: scale(0.75) rotate(55deg);
    opacity: 1;
  }
  
  5%,
  15%,
  25% {
    transform: scale(1) rotate(55deg);
  }
  
  10%,
  20% {
    transform: scale(0.75) rotate(55deg);
  }
  
  70% {
    opacity: 1;
  }
  
  100% {
    transform: rotate(55deg) translateY(-10px) translateX(-10px);
    opacity: 0;
  }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值