div+css实现三维奔跑的狮子动画效果代码

代码语言:html

所属分类:三维

代码描述:div+css实现三维奔跑的狮子动画效果代码

代码标签: div css 三维 奔跑 狮子 动画

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

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

<head>

  <meta charset="UTF-8">

  
  
<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background-image: radial-gradient(#333, #0a0a0a);
  overflow: hidden;
  perspective: 1000px;
}
body .scene, body .scene * {
  transform-style: preserve-3d;
}
body .scene {
  position: relative;
  width: 70vmin;
  height: 20vmin;
  transform: rotateX(-20deg) rotateY(50deg);
  animation: rot 30s ease-in-out 0s infinite alternate;
}
@keyframes rot {
  to {
    transform: rotateX(0deg) rotateY(440deg);
  }
}
body .scene::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  z-index: -100;
  transform: rotateX(90deg) scale(1);
}
body .scene .cube, body .scene .cube *, body .scene .lion, body .scene .lion * {
  position: absolute;
  bottom: 0;
}
body .scene #ground {
  z-index: -50;
  width: 70vmin;
  height: 3vmin;
  transform: translateY(3vmin);
}
body .scene #ground .container {
  position: relative;
  width: 100%;
  height: 100%;
}
body .scene #ground .container * {
  position: absolute;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
body .scene #ground .container .left {
  width: 70vmin;
  height: 3vmin;
  background-color: #9a5e30;
  transform-origin: left top;
  transform: rotateY(-90deg) translateX(-35vmin);
}
body .scene #ground .container .right {
  width: 70vmin;
  height: 3vmin;
  background-color: #9a5e30;
  transform-origin: left top;
  transform: rotateY(90deg) translateX(-35vmin) translateZ(70vmin);
}
body .scene #ground .container .top {
  background-color: #ae6a36;
  width: 70vmin;
  height: 70vmin;
  transform-origin: bottom left;
  transform: rotateX(90deg) translateY(35vmin) translateZ(3vmin);
}
body .scene #ground .container .bottom {
  background-color: #ae6a36;
  width: 70vmin;
  height: 70vmin;
  transform-origin: bottom left;
  transform: rotateX(-90deg) translateY(35vmin);
}
body .scene #ground .container .front {
  background-color: #7b4b27;
  width: 70vmin;
  height: 3vmin;
  transform-origin: bottom left;
  transform: translateZ(35vmin);
}
body .scene #ground .container .back {
  background-color: #7b4b27;
  width: 70vmin;
  height: 3vmin;
  transform-origin: center;
  transform: rotateY(180deg) translateZ(35vmin) rotateX(180deg) rotateZ(180deg);
}
body .scene #ground .container .left, body .scene #ground .container .right, body .scene #ground .container .front, body .scene #ground .container .back {
  display: none;
}
body .scene #ground .container .bottom {
  filter: drop-shadow(0 0 0.75vmin black);
  background: #111;
  border-radius: 10%;
}
body .scene #ground .container .top {
  box-shadow: inset 0 0 15vmin #000a;
  border-radius: 10%;
  background-image: radial-gradient(#0004, #0000 15vmin), linear-gradient(to bottom, #0000 30%, #87522a 30% 70%, #0000 70% 100%), repeating-linear-gradient(180deg, #0000 0% 50%, #0001 50% 100%), repeating-linear-gradient(90deg, #0000 0% 50%, #0001 50% 100%);
  background-size: 100%, 100%, 8vmin 8vmin, 8vmin 8vmin;
  animation: floorMove 0.2s infinite linear;
}
@keyframes floorMove {
  to {
    background-position-x: center, center, 8vmin, 8vmin;
  }
}
body .scene #ground .container .top::after {
  content: "";
  position: absolute;
  width: 25%;
  height: 25%;
  background: #0001;
  box-shadow: 0 0 8vmin #0002;
  animation: scaleShadow 0.3s linear 0.35s infinite alternate;
}
@keyframes scaleShadow {
  from {
    transform: scale(0.8);
  }
  to {
    transform: scale(1);
  }
}
body .scene .lion {
  position: absolute;
  width: 15vmin;
  height: 15vmin;
  bottom: 0;
  transform-origin: 7.5vmin 7.5vmin;
  transform: translate3d(27vmin, -4vmin, 0vmin);
  animation: animate-lion 0.6s ease-in-out infinite;
}
@keyframes animate-lion {
  0%, 100% {
    transform: translate3d(27vmin, -4vmin, 0vmin);
  }
  33% {
    transform: translate3d(27vmin, -8vmin, 0vmin) rotateZ(10deg) rotateX(-5deg);
  }
  66% {
    transform: translate3d(27vmin, -7vmin, 0vmin) rotateZ(-10deg) rotateX(5deg);
  }
}
body .scene .lion ._face {
  position: absolute;
  bottom: 0;
}
body .scene .lion .body {
  width: 15vmin;
  height: 15vmin;
}
body .scene .lion .body #body {
  width: 15vmin;
  height: 15vmin;
  transform: translate3d(0vmin, 0vmin, 0vmin);
}
body .scene .lion .body #body .container {
  position: relative;
  width: 100%;
  height: 100%;
}
body .scene .lion .body #body .container * {
  position: absolute;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
body .scene .lion .body #body .container .left {
  width: 15vmin;
  height: 15vmin;
  background-color: #C8834F;
  transform-origin: left top;
  transform: rotateY(-90deg) translateX(-7.5vmin);
}
body .scene .lion .body #body .container .right {
  width: 15vmin;
  height: 15vmin;
  background-color: #C8834F;
  transform-origin: left top;
  transform: rotateY(90deg) translateX(-7.5vmin) translateZ(15vmin);
}
body .scene .lion .body #body .container .top {
  background-color: #ce9162;
  width: 15vmin;
  height: 15vmin;
  transform-origin: bottom left;
  transform: rotateX(90deg) translateY(7.5vmin) translateZ(15vmin);
}
body .scene .lion .body #body .container .bottom {
  background-color: #ce9162;
  width: 15vmin;
  height: 15vmin;
  transform-origin: bottom left;
  transform: rotateX(-90deg) translateY(7.5vmin);
}
body .scene .lion .body #body .container .front {
  background-color: #b56e39;
  width: 15vmin;
  height: 15vmin;
  transform-origin: bottom left;
  transform: translateZ(7.5vmin);
}
body .scene .lion .body #body .container .back {
  background-color: #b56e39;
  width: 15vmin;
  height: 15vmin;
  transform-origin: center;
  transform: rotateY(180deg) translateZ(7.5vmin) rotateX(180deg) rotateZ(180deg);
}
body .scene .lion .body #body .container .right {
  background-image: linear-gradient(to top, #0000 2vmin, #783D2A 2vmin, #0000 15vmin), linear-gradient(to bottom, #C8834F 12vmin, transparent 13vmin 15vmin), linear-gradient(to right, transparent 4vmin, #E4DDB7 4vmin 11vmin, transparent 11vmin 15vmin);
}
body .scene .lion .body .mane {
  width: 100%;
  height: 100%;
}
body .scene .lion .body .mane #mane {
  width: 10vmin;
  height: 13.3vmin;
  transform: translate3d(0vmin, -2vmin, 0vmin);
}
body .scene .lion .body .mane #mane .container {
  position: relative;
  width: 100%;
  height: 100%;
}
body .scene .lion .body .mane #mane .container * {
  position: absolute;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
body .scene .lion .body .mane #mane .container .left {
  width: 16vmin;
  height: 13.3vmin;
  background-color: #783D2A;
  transform-origin: left top;
  transform: rotateY(-90deg) translateX(-8vmin);
}
body .scene .lion .body .mane #mane .container .right {
  width: 16vmin;
  height: 13.3vmin;
  background-color: #783D2A;
  transform-origin: left top;
  transform: rotateY(90deg) translateX(-8vmin) translateZ(10vmin);
}
body .scene .lion .body .mane #mane .container .top {
  background-color: #8b4731;
  width: 10vmin;
  height: 16vmin;
  transform-origin: bottom left;
  transform: rotateX(90deg) translateY(8vmin) translateZ(13.3vmin);
}
body .scene .lion .body .mane #mane .container .bottom {
  background-color: #8b4731;
  width: 10vmin;
  height: 16vmin;
  transform-origin: bottom left;
  transform: rotateX(-90deg) translateY(8vmin);
}
body .scene .lion .body .mane #mane .container .front {
  background-color: #5a2e1f;
  width: 10vmin;
  height: 13.3vmin;
  transform-origin: bottom left;
  transform: translateZ(8v.........完整代码请登录后点击上方下载按钮下载查看

网友评论0