js+css实现跟随眼睛鼠标交互的黑猫效果代码

代码语言:html

所属分类:其他

代码描述:js+css实现跟随眼睛鼠标交互的黑猫效果代码

代码标签: js css 跟随 眼睛 鼠标 交互 黑猫

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

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

<head>
  <meta charset="UTF-8">
  

  
  
  
<style>
html, body, .container {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: linear-gradient(skyblue, dodgerblue);
}

div {
  position: absolute;
  box-sizing: border-box;
}

.face {
  height: 200px;
  width: 200px;
  background: black;
  border-radius: 100%;
}

[class^=cheek] {
  height: 80px;
  width: 80px;
  background: #111;
  border-radius: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 -30px 20px gray;
}

.cheek-left {
  transform: translateX(-50px) translateY(10px);
}

.cheek-right {
  transform: translateX(50px) translateY(10px);
}

.snoot {
  height: 130px;
  width: 130px;
  background: gray;
  border-radius: 100%;
  transform: translateY(50px);
}

[class^=eye] {
  height: 60%;
  width: 60%;
  background: linear-gradient(to top, mediumseagreen 50%, black);
  border-width: 1px 6px;
  border-color: black;
  border-style: solid;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 0px 20px 0px black;
}

.eye-left {
  border-radius: 40% 100% 30% 100%;
}

.eye-right {
  border-radius: 100% 30% 100% 40%;
}

.pupil {
  height: 50px;
  width: 30px;
  background: black;
  border-radius: 100%;
  transform: translateY(-5px);
}

.sparkle {
  content: "";
  display: block;
  background: rgba(255, 255, 255, 0.2);
  height: 40px;
  width: 40px;
  border-radius: 100%;
  transform: translateY(-16px);
}

.nose-bridge {
  height: 80px;
  width: 50px;
  background: linear-gradient(to top, #aaa, #222 60%);
  transform: translateY(20px);
  display: flex;
  align-items: flex-end;
}

.nose {
  width: 50px;
  height: 30px;
  background: linear-gradient(to top, #a44, #e99);
  border-radius: 20%;
  transform: translateY(20px);
}

[class^=lip] {
  height: 50px;
  width: 60px;
  background: linear-gradient(to bottom, #777, #bbb);
  border-radius: 100%;
  display: flex;
  flex-direction: column;
  line-height: 40%;
  justify-content: center;
  align-items: center;
}

.lip-left {
  transform: translateX(-32px) translateY(80px);
}

.lip-right {
  transform: translateX(32px) translateY(80px);
}

[class^=ear] {
  background: linear-gradient(45deg, black, #855);
  height: 160px;
  width: 160px;
  border-radius: 20% 50% 20% 50%;
  border-style: solid;
  border-width: 10px 0 0 10px;
  border-color: black;
}

@keyframes jiggle {
  0% {
    transform: translateY(20px) translateX(-10px) rotate(-37deg) translateY(-80px) rotate(10deg) scaleX(0.6) rotate(45deg);
  }
  3% {
    transform: translateY(20px) translateX(-10px) rotate(-42deg) translateY(-80px) rotate(10deg) scaleX(0.6) rotate(45deg);
  }
  6% {
    transform: translateY(20px) translateX(-10px) rotate(-39deg) translateY(-80px) rotate(10deg) scaleX(0.6) rotate(45deg);
  }
  9% {
    transform: translateY(20px) translateX(-10px) rotate(-40deg) translateY(-80px) rotate(10deg) scaleX(0.6) rotate(45deg);
  }
  100% {
    transform: translateY(20px) translateX(-10px) rotate(-40deg) translateY(-80px) rotate(10deg) scaleX(0.6) rotate(45deg);
  }
}
@keyframes jiggle-2 {
  0% {
    transform: rotateY(180deg) translateY(20px) translateX(-10px) rotate(-37deg) translateY(-80px) rotate(10deg) scaleX(0.6) rotate(45deg);
  }
  2% {
    transform: rotateY(180deg) translateY(20px) translateX(-10px) rotate(-42deg) translateY(-80px) rotate(10deg) scaleX(0.6) rotate(45deg);
  }
  4% {
    transform: rotateY(180deg) translateY(20px) translateX(-10px) rotate(-39deg) translateY(-80px) rotate(10deg) scaleX(0.6) rotate(45deg);
  }
  6% {
    transform: rotateY(180deg) translateY(20px) translateX(-10px) rotate(-40deg) translateY(-80px) rotate(10deg) scaleX(0.6) rotate(45deg);
  }
  100% {
    transform: rotateY(180deg) translateY(20px) translateX(-10px) rotate(-40deg) translateY(-80px) rotate(10deg) scaleX(0.6) rotate(45deg);
  }
}
.ear-left {
  transform: translateY(20px) translateX(-10px) rotate(-40deg) translateY(-80px) rotate(10deg) scaleX(0.6) r.........完整代码请登录后点击上方下载按钮下载查看

网友评论0