css偷鸡蛋交互效果

代码语言:html

所属分类:动画

代码描述:css偷鸡蛋交互效果

代码标签: 交互 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
:root {
  --sizeVar: clamp(100px, 20vw, 50vh);
}
body {
  background-color: black;
  overflow: hidden;
}
div,
a {
  position: absolute;
}
.chickenDiv {
  width: 20vw;
  width: var(--sizeVar);
  height: 20vw;
  height: var(--sizeVar);
  bottom: 20%;
  left: 50%;
  margin-left: -10vw;
  margin-left: calc(var(--sizeVar) / -2);
  -webkit-animation: none 300ms linear;
          animation: none 300ms linear;
}
.chickenDiv,
.chickenDiv:focus,
.chickenDiv:active {
  -webkit-tap-highlight-color: transparent;
}
.bgDiv {
  width: 110%;
  height: 110%;
  left: 0%;
  top: -10%;
  border-radius: 50%;
  background-color: rgb(2, 0, 36);
  background: -webkit-gradient(
    linear,
    left bottom, left top,
    from(rgba(2, 0, 36, 1)),
    color-stop(35%, rgba(80, 9, 121, 1)),
    to(rgba(239, 0, 255, 1))
  );
  background: linear-gradient(
    0deg,
    rgba(2, 0, 36, 1) 0%,
    rgba(80, 9, 121, 1) 35%,
    rgba(239, 0, 255, 1) 100%
  );
  z-index: -2;
}
.chickenDiv::after,
.chickenDiv::before {
  position: absolute;
  content: "";
  width: 80%;
  height: 15%;
  left: 10%;
  border-radius: 50%;
}
.chickenDiv::after {
  bottom: -7%;
  -webkit-clip-path: polygon(0 54%, 100% 54%, 100% 100%, 0% 100%);
          clip-path: polygon(0 54%, 100% 54%, 100% 100%, 0% 100%);
  border-bottom: 2vw solid rgb(117, 80, 56);
  border-bottom: calc(var(--sizeVar) / 10) solid rgb(117, 80, 56);
}
.chickenDiv::before {
  bottom: -2%;
  background-color: rgb(95, 62, 41);
}
body a:nth-of-type(2) {
  left: 20%;
}
body a:nth-of-type(3) {
  left: 80%;
}
.chickenBody {
  width: 80%;
  height: 60%;
  bottom: 0;
  left: 10%;
  background-color: whitesmoke;
  border-radius: 50% 0 50% 50%;
  border-radius: 50% 50% 50% 50% / 50% 20% 80% 50%;
  -webkit-animation: reverseChicken 300ms linear;
          animation: reverseChicken 300ms linear;
  -webkit-animation-fill-mode: both;
          animation-fill-mode: both;
  pointer-events: none;
}
.chickenBody .chickenHead {
  height: 50%;
  width: 40%;
  border-radius: 50%;
  left: -15%;
  top: 0;
  background-color: whitesmoke;
  -webkit-animation: reverseHead 400ms linear;
          animation: reverseHead 400ms linear;
  -webkit-animation-fill-mode: both;
          animation-fill-mode: both;
}
.chickenBody .chickenCrest,
.chickenBody .chickenCrest::after,
.chickenBody .chickenCrest::before {
  width: 30%;
  height: 30%;
  background-color: red;
  top: -30%;
  -webkit-transform: translate(100%, 20%) scale(1, 1);
          transform: translate(100%, 20%) scale(1, 1);
  -webkit-transform-origin: center bottom;
          transform-origin: center bottom;
  border-radius: 50% 50% 0 0;
  z-index: -1;
}
.chickenBody .chickenCrest {
  -webkit-animation: reverseCrest 600ms linear;
          animation: reverseCrest 600ms linear;
}
.chickenBody:target .chickenCrest {
  -webkit-animation-name: crestAnim;
          animation-name: crestAnim;
}
.chickenBody .chickenCrest::after,
.chickenBody .chickenCrest::before {
  position: absolute;
  content: "";
  width: 100%;
  height: 80%;
  top: auto;
  bottom: 0;
  -webkit-transform: rotate(25deg) translateX(60%);
          transform: rotate(25deg) translateX(60%);
}
.chickenBody .chickenCrest::before {
  -webkit-transform: rotate(-25deg) translateX(-60%);
          transform: rotate(-25deg) translateX(-60%);
}
.chickenBody .chickenHead::after {
  position: absolute;
  content: "";
  width: 20%;
  height: 20%;
  top: 50%;
  background-color: orange;
  -webkit-transform: rotate(-45deg);
          transform: rotate(-45deg);
  border-radius: 20% 80% 50% 50% / 20% 50% 50% 80%;
}
.chickenHead .chickenEye {
  width: 10%;
  height: 10%;
  top: 30%;
  left: 5%;
  border-radius: 50%;
  background-color: black;
  -webkit-animation: eyeAnim 3000ms linear infinite;
          animation: eyeAnim 3000ms linear infinite;
}
.chickenHead .chickenEye:nth-of-type(2) {
  left: 25%;
}
.chickenDiv:nth-of-type(2) .chickenHead .chickenEye {
  -webkit-animation-delay: 1000ms;
          animation-delay: 1000ms;
}
.chickenDiv:nth-of-type(3) .chickenHead .chickenEye {
  -webkit-animation-delay: 1500ms;
          animation-delay: 1500ms;
}
.chickenBody:target .chickenHead {
  -webkit-animation-name: headAnim;
          animation-name: headAnim;
}
.chickenBody:target {
  -webkit-animation-name: chichenAnim;
          animation-name: chichenAnim;
}
.chickenLeg {
  width: 4%;
  height: 41%;
  bottom: 0;
  left: 55%;
  background-color: orange;
}
.chickenLeg:nth-of-type(2) {
  left: 45%;
}
.eggWrapper {
  width: 100%;
  height: 100%;
  -webkit-animation: eggBlink 400ms steps(1) infinite;
          animation: eggBlink 400ms steps(1) infinite;
  -webkit-animation-play-state: running;
          animation-play-state: running;
}
.chickenBody:target .eggWrapper {
  -webkit-animation-play-state: paused;
          animation-play-state: paused;
}
.eggDiv {
  width: 40%;
  height: 50%;
  left: 25%;
  top: 20%;
  background-color: whitesmoke;
  border-radius: 20% 80% 50% 50% / 20% 50% 50% 80%;
  z-index: 0;
  -webkit-animation: eggReverse 500ms linear 0s;
          animation: eggReverse 500ms linear 0s;
  -webkit-animation-fill-mode: forwards;
          animation-fill-mode: forwards;
}
.chickenBody:target .eggDiv {
  -webkit-animation: eggDrop 500ms ease-in 500ms;
          animation: eggDrop 500ms ease-in 500ms;
  -webkit-animation-fill-mode: forwards;
          animation-fill-mode: forwards;
}
p {
  position: absolute;
  bottom: 8px;
  left: 0;
  width: 100%;
  text-align: center;
  color: whitesmoke;
  font-family: sans-serif;
  font-size: 1em;
}
p a {
  position: relative;
  color: rgba(239, 0, 255, 0.8);
  margin-left: 8px;
}
@-webkit-keyframes eggBlink {
  0% {
    visibility: hidden;
  }
  50% {
    visibility: visible;
  }
}
@keyframes eggBlink {
  0% {
    visibility: hidden;
  }
  50% {
    visibility: visible;
  }
}
@-webkit-keyframes chichenAnim {
  0% {
    bottom: 0;
    height: 60%;
    width: 80%;
    left: 10%;
  }
  30% {
    bottom: 0;
    height: 40%;
    width: 100%;
    left: 0;
  }
  60% {
    bottom: 10%;
    height: 90%;
    width: 60%;
    left: 20%;
  }
  100% {
    bottom: 40%;
    height: 60%;
    width: 80%;
    left: 10%;
  }
}
@keyframes chichenAnim {
  0% {
    bottom: 0;
    height: 60%;
    width: 80%;
    left: 10%;
  }
  30% {
    bottom: 0;
    height: 40%;
    width: 100%;
    left: 0;
  }
  60% {
    bottom: 10%;
    height: 90%;
    width: 60%;
    left: 20%;
  }
  100% {
    bottom: 40%;
    height: 60%;
    width: 80%;
    left: 10%;
  }
}
@-webkit-keyframes reverseChicken {
  0% {
    bottom: 40%;
    height: 60%;
    width: 80%;
    left: 10%;
  }
  30% {
    bottom: 10%;
    height: 90%;
    width: 60%;
    left: 20%;
  }
  60% {
    bottom: 0;
    height: 40%;
    width: 100%;
    left: 0;
  }
  100% {
    bottom: 0;
    height: 60%;
    width: 80%;
    left: 10%;
  }
}
@keyframes reverseChicken {
  0% {
    bottom: 40%;
    height: 60%;
    width: 80%;
    left: 10%;
  }
  30% {
    bottom: 10%;
    height: 90%;
    width: 60%;
    left: 20%;
  }
  60% {
    bottom: 0;
    height: 40%;
    width: 100%;
    left: 0;
  }
  100% {
    bottom: 0;
    height: 60%;
    width: 80%;
    left: 10%;
  }
}
@-webkit-keyframes headAnim {
  0% {
    top: 0;
  }
  40% {
    top: 50%;
  }
  80% {
    top: -20%;
  }
  100% {
    top: 0;
  }
}
@keyframes headAnim {
  0% {
    top: 0;
  }
  40% {
    top: 50%;
  }
  80% {
    top: -20%;
  }
  100% {
    top: 0;
  }
}
@-webkit-keyframes reverseHead {
  0% {
    top: 0;
  }
  20% {
    top: -20%;
  }
  60% {
    top: 40%;
  }
  100% {
    top: 0;
  }
}
@keyframes reverseHead {
  0% {
    top: 0;
  }
  20% {
    top: -20%;
  }.........完整代码请登录后点击上方下载按钮下载查看

网友评论0