css实现可爱小老虎点击翻转屁股摇尾巴效果代码

代码语言:html

所属分类:动画

代码描述:css实现可爱小老虎点击翻转屁股摇尾巴效果代码

代码标签: css 可爱 老虎 尾巴

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


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">
  

  
  
<style>
@-webkit-keyframes blinky {
  0%, 9%, 11%, 19%, 21%, 69%, 71%, 100% {
    transform: scaleY(1);
  }
  10%, 20%, 70% {
    transform: scaleY(0);
  }
}
@keyframes blinky {
  0%, 9%, 11%, 19%, 21%, 69%, 71%, 100% {
    transform: scaleY(1);
  }
  10%, 20%, 70% {
    transform: scaleY(0);
  }
}
:root {
  --black: #624a29;
  --white: #fff;
  --primary-color: #ff9c6a;
  --primary-color-dark: #ee7331;
  --primary-color-tint: #fdb490;
  --secondary-color: #fff6a4;
  --secondary-color-tint: #fffcdf;
  --secondary-color-dark: #f5d79d;
  --accent-color: #ff6a6a;
  --background: var(--primary-color-tint);
  --circle-sizing: 18rem;
  --circle-rotate: 0deg;
}

* {
  box-sizing: border-box;
}

body {
  display: grid;
  place-items: center;
  height: 100vh;
  background-color: var(--background);
  font-size: 16px;
  line-height: 1;
  overflow-x: hidden;
}

.tiger {
  position: relative;
  height: var(--circle-sizing);
  width: var(--circle-sizing);
  transform-style: preserve-3d;
  transform: rotateY(var(--circle-rotate));
  transition: 0.5s ease-in-out;
  cursor: pointer;
}
.tiger *,
.tiger *::before,
.tiger *::after {
  position: absolute;
}
.tiger-eye {
  border-top-left-radius: 50% 60%;
  border-top-right-radius: 50% 60%;
  border-bottom-right-radius: 50% 40%;
  border-bottom-left-radius: 50% 40%;
  --position: 3rem;
  z-index: 5;
  top: 5.5rem;
  height: 1.125rem;
  width: 0.875rem;
  transform-origin: center 70%;
  background-color: var(--black);
  -webkit-animation: blinky 7s infinite;
          animation: blinky 7s infinite;
}
.tiger-eye-left {
  left: var(--position);
}
.tiger-eye-right {
  right: var(--position);
}
.tiger-eyebrow {
  --position: 2rem;
  --flip: 1;
  z-index: 2;
  top: 3.75rem;
  height: 1.25rem;
  width: 1.5rem;
  transform: rotate(calc(20deg * var(--flip)));
  border-radius: 100%;
  background-color: var(--secondary-color);
}
.tiger-eyebrow-left {
  left: var(--position);
}
.tiger-eyebrow-right {
  right: var(--position);
}
.tiger-eyebrow-left {
  --flip: -1;
}
.tiger-nose {
  --sizing: 1rem;
  z-index: 4;
  top: 6rem;
  left: calc(50% - (var(--sizing) / 2));
  height: var(--sizing);
  width: var(--sizing);
  transform: rotate(45deg);
  border-top-left-radius: 100%;
  border-top-right-radius: 30%;
  border-bottom-left-radius: 30%;
  border-bottom-right-radius: 0.125rem;
  background-color: var(--accent-color);
}
.tiger-snout {
  --offset: -0.125rem;
  --flipper: 1;
  z-index: 2;
  top: 6.5rem;
  left: 50%;
  height: 2.25rem;
  width: 2rem;
}
.tiger-snout::before, .tiger-snout::after {
  content: "";
  top: 0;
  height: 100%;
  width: 100%;
  border-radius: 100%;
  background-color: var(--secondary-color);
  transform: rotate(calc(50deg * var(--flipper)));
}
.tiger-snout::before {
  right: calc(100% + var(--offset));
}
.tiger-snout::after {
  --flipper: -1;
  left: var(--offset);
}
.tiger-blush {
  --position: 1.5rem;
  z-index: 2;
  top: 6rem;
  height: 1.75rem;
  width: 2.25rem;
  border-radius: 100%;
  background-color: var(--accent-color);
  opacity: 0.5;
}
.tiger-blush-left {
  left: var(--position);
}
.tiger-blush-right {
  right: var(--position);
}
.tiger-face-fluff {
  --position: 1.25rem;
  --flip: 1;
  --before-pos: -0.75rem;
  z-index: 1;
  bottom: 0rem;
  height: 3rem;
  width: 1.75rem;
  transform: rotate(calc(70deg * var(--flip)));
  transform-origin: center top;
  border-bottom-left-radius: 50% 100%;
  border-bottom-right-radius: 50% 100%;
  background-color: var(--primary-color);
}
.tiger-face-fluff-left {
  left: var(--position);
}
.tiger-face-fluff-right {
  right: var(--position);
}
.tiger-face-fluff::before {
  content: "";
  bottom: 0.25rem;
  left: var(--left);
  right: var(--right);
  height: 2rem;
  width: 1.5rem;
  transform: rotate(calc(-10deg * var(--flip)));
  border-radius: inherit;
  background-color: inherit;
}
.tiger-face-fluff-right {
  --flip: -1;
  --right: var(--before-pos);
}
.tiger-face-fluff-left {
  --left: var(--before-pos);
}
.tiger-stripes-top {
  top: 0;
  height: 4rem;
  width: 1rem;
  border-bottom-left-radius: 50%;
  border-bottom-right-radius: 50%;
  background-color: var(--black);
}
.tiger-stripes-top, .tiger-stripes-top::before, .tiger-stripes-top::after {
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--black);
}
.tiger-stripes-top::before, .tiger-stripes-top::after {
  content: "";
  height: 0.75rem;
  border-radius: 50%;
}
.tiger-stripes-top::before {
  top: 0.75rem;
  width: 3rem;
}
.tiger-stripes-top::after {
  top: 2rem;
  width: 2.5rem;
}
.tiger-stripes-side {
  --position: -0.5rem;
  --flip: 1;
  top: 5.5rem;
}
.tiger-stripes-side-left {
  left: var(--position);
}
.tiger-stripes-side-right {
  right: var(--position);
}
.tiger-stripes-side::before, .tiger-stripes-side::after {
  content: "";
  width: 0.75rem;
  transform-origin: center top;
  border-bottom-left-radius: 50% 100%;
  border-bottom-right-radius: 50% 100%;
  background-color: var(--black);
}
.tiger-stripes-side::before {
  height: 1.25rem;
  transform: rotate(calc(85deg * var(--flip)));
}
.tiger-stripes-side::after {
  top: 1rem;
  height: 1rem;
  transform: rotate(calc(90deg * var(--flip)));
}
.tiger-stripes-side-left {
  --flip: -1;
}
.tiger-stripes-side-right::before, .tiger-stripes-side-right::after {
  right: 0;
}
.tiger-face {
  border-top-left-radius: 50% 65%;
  border-top-right-radius: 50% 65%;
  border-bottom-right-radius: 50% 35%;
  border-bottom-left-radius: 50% 35%;
  z-index: 5;
  inset: 0;
  background-color: var(--primary-color);
}
.tiger-face-mask {
  background-color: transparent;
  overflow: hidden;
}
.tiger-ear {
  --position: -0.5rem;
  --flip: 1;
  --inner-position: -2rem;
  z-index: 1;
  top: 0.75rem;
  height: 3rem;
  width: 3.5rem;
  transform: rotate(calc(50deg * var(--flip)));
  border-radius: 50%/40%;
  background-color: var(--primary-color);
  overflow: hidden;
}
.tiger-ear-left {
  left: var(--position);
}
.tiger-ear-right {
  right: var(--position);
}
.tiger-ear::before, .tiger-ear::after {
  content: "";
}
.tiger-ear::before {
  inset: 1rem;
  border-radius: 50%;
  background-color: var(--accent-color);
}
.tiger-ear::after {
  top: -1rem;
  left: var(--inner-left);
  right: var(--inner-right);
  height: 2rem;
  width: 4rem;
  transform: rotate(calc(-10deg * var(--flip)));
  border-radius: 100%;
  background-color: var(--black);
}
.tiger-ear-left {
  --flip: -1;
  --inner-right: var(--inner-position);
}
.tiger-ear-right {
  --inner-left: var(--inner-position);
  -webkit-animation: earTwitch 3s infinite;
          animation: earTwitch 3s infinite;
}
.tiger-head {
  z-index: 2;
  bottom: 1.5rem;
  left: 50%;
  height: 11rem;
  width: 13rem;
  transform: translateX(-50%) translateY(var(--head-translate-y, 0));
  transform-origin: center bottom;
  transition: 0.4s ease-out;
}
.tiger-head::before {
  content: "";
  left: 50%;
  bottom: -1rem;
  height: 3rem;
  width: 4rem;
  transform: translateX(-50%);
  border-radius: 100%;
  background-color: var(--secondary-color-dark);
}
.tiger-paw {
  --position: 1.5rem;
  --flip: 1;
  z-index: 6;
  bottom: 0;
  height: 3rem;
  width: 4rem;
  transform: rotate(calc(20deg * var(--flip)));
  background-color: var(--secondary-color);
  border-radius: 2rem;
}
.tiger-paw-left {
  left: var(--position);
}
.tiger-paw-right {
  right: var(--position);
}
.tiger-paw::before, .tiger-paw::after {
  content: "";
  left: 50%;
  transform: translateX(-50%);
}
.tiger-paw::before {
  z-index: 1;
  bottom: -0.25rem;
  height: 80%;
  width: 2rem;
  border-radius: 1rem;
  background-color: var(--secondary-color);
}
.tiger-paw::after {
  bottom: 0;
  width: 2.5rem;
  height: 50%;
  border-radius: 1.5rem;
  background-color: var(--secondary-color-dark);
}
.tiger-paw-right {
  --flip: -1;
}
.tiger-chest {
  border-top-left-radius: 50% 80%;
  border-top-right-radius: 50% 80%;
  border-bottom-right-radius: 50% 20%;
  border-bottom-left-radius: 50% 20%;
  inset: 0;
  background-color: var(--primary-color);
}
.tiger-chest::before {
  content: "";
  left: 50%;
  height: 100%;
  width: 65%;
  transform: translateX(-50%);
  border-radius: inherit;
  background-color: var(--secondary-color);
}
.tiger-body {
  bottom: -2rem;
  left: 50%;
  width: 10rem;
  height: 8rem;
  transform: translateX(-50%);
}
.tiger-front {
  background-color: var(--secondary-color-tint);
  transform: translateZ(0.25rem);
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
}
.tiger-front, .tiger-front-mask {
  inset: 0;
  border-radius: 100%;
}
.tiger-front-mask {
  overflow: hidden;
  transform: translateZ(0);
}
.tiger-cross {
  --flip: 1;
  top: 4.5rem;
  left: 50%;
  height: 1.5rem;
  width: 1.5rem;
  transform: translateX(-50%);
}
.tiger-cross::before, .tiger-cross::after {
  content: "";
  left: 50%;
  height: 100%;
  width: 0.5rem;
  border-radius: 50%;
  background-color: var(--primary-color-dark);
  transform: translateX(-50%) rotate(calc(45deg * var(--flip)));
}
.tiger-cross::before {
  --flip: -1;
}
.tiger-tail {
  inset: 0;
  transform-origin: 50% 95%;
  transform: rotate(30deg);
  border-radius: inherit;
  background-color: var(--primary-color);
  overflow: hidden;
}
.tiger-tail::before {
  content: "";
  height: 1.5rem;
  width: 150%;
  left: -50%;
  border-radius: 100%;
  background-color: var(--black);
}
.tiger-tail-stripes {
  top: 2.5rem;
  left: -0.25rem;
  width: 2rem;
}
.tiger-tail-stripes::before, .tiger-tail-stripes::after {
  content: "";
  height: 1rem;
  width: 100%;
  border-top-right-radius: 100% 50%;
  border-bottom-right-radius: 100% 50%;
  background-color: var(--black);
}
.tiger-tail-stripes::after {
  top: 1.5rem;
  left: -0.5rem;
}
.tiger-tail, .tiger-tail-wrap::before {
  -webkit-animation: tailWiggle 2s ease-in infinite;
          animation: tailWiggle 2s ease-in infinite;
}
.tiger-tail-wrap {
  top: -3.5rem;
  left: 50%;
  height: 7.5rem;
  width: 3rem;
  transform: translateX(-50%);
  border-radius: 40% 60% 50% 50%/20% 30% 70% 80%;
}
.tiger-tail-wrap::before {
  content: "";
  z-index: -1;
  left: 0rem;
  bottom: 0.25rem;
  height: 58%;
  width: 3rem;
  transform-origin: center bottom;
  transform: rotate(50deg);
  border-radius: inherit;
  background-color: var(--primary-color-dark);
  -webkit-animation-name: tailWig.........完整代码请登录后点击上方下载按钮下载查看

网友评论0