div+css实现三维绝地武士动画效果代码

代码语言:html

所属分类:三维

代码描述:div+css实现三维绝地武士动画效果代码

代码标签: div css 三维 绝地 武士 动画

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


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

<head>


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

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background-image: radial-gradient(#bd8b56, #6a4a29);
  overflow: hidden;
  perspective: 1000px;
}
body .scene, body .scene * {
  transform-style: preserve-3d;
}
body .scene {
  position: relative;
  width: 70vmin;
  height: 70vmin;
  margin-top: -40%;
  transform: rotateX(-20deg) rotateY(70deg) scale3d(1, 1, 1);
  animation: rot 20s ease-in-out 0s infinite alternate;
}
@keyframes rot {
  to {
    transform: rotateX(0deg) rotateY(440deg) scale3d(1, 1, 1);
  }
}
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 * {
  position: absolute;
  bottom: 0;
}
body .scene #ground {
  z-index: -50;
  width: 70vmin;
  height: 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: #BC7D3D;
  transform-origin: left top;
  transform: rotateY(-90deg) translateX(-35vmin);
}
body .scene #ground .container .right {
  width: 70vmin;
  height: 3vmin;
  background-color: #BC7D3D;
  transform-origin: left top;
  transform: rotateY(90deg) translateX(-35vmin) translateZ(70vmin);
}
body .scene #ground .container .top {
  background-color: #c58a4d;
  width: 70vmin;
  height: 70vmin;
  transform-origin: bottom left;
  transform: rotateX(90deg) translateY(35vmin) translateZ(3vmin);
}
body .scene #ground .container .bottom {
  background-color: #c58a4d;
  width: 70vmin;
  height: 70vmin;
  transform-origin: bottom left;
  transform: rotateX(-90deg) translateY(35vmin);
}
body .scene #ground .container .front {
  background-color: #9d6933;
  width: 70vmin;
  height: 3vmin;
  transform-origin: bottom left;
  transform: translateZ(35vmin);
}
body .scene #ground .container .back {
  background-color: #9d6933;
  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 {
  background-image: linear-gradient(180deg, #0000 0% 20%, #AD6B2B 20% 45%, #0000 45% 100%);
}
body .scene #ground .container .bottom {
  background-color: #E1B366;
  filter: drop-shadow(0 0 3.75rem black);
}
body .scene #ground .container .top {
  box-shadow: inset 0 0 15vmin #000a;
  background-image: radial-gradient(#0008, #0000 15vmin), repeating-linear-gradient(180deg, #0000 0% 50%, #0001 50% 100%), repeating-linear-gradient(90deg, #0000 0% 50%, #0001 50% 100%);
  background-size: 100%, 4em 4em, 4em 4em;
}
body .scene .rocks {
  position: absolute;
  width: 100%;
  height: 100%;
  bottom: 0;
  transform: translateY(-3vmin);
}
body .scene .rocks #rock-1 {
  width: 6vmin;
  height: 5vmin;
  transform: translate3d(5vmin, 2vmin, 25vmin) rotateX(15deg) rotateY(15deg);
}
body .scene .rocks #rock-1 .container {
  position: relative;
  width: 100%;
  height: 100%;
}
body .scene .rocks #rock-1 .container * {
  position: absolute;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
body .scene .rocks #rock-1 .container .left {
  width: 5vmin;
  height: 5vmin;
  background-color: #3D3D3D;
  transform-origin: left top;
  transform: rotateY(-90deg) translateX(-2.5vmin);
}
body .scene .rocks #rock-1 .container .right {
  width: 5vmin;
  height: 5vmin;
  background-color: #3D3D3D;
  transform-origin: left top;
  transform: rotateY(90deg) translateX(-2.5vmin) translateZ(6vmin);
}
body .scene .rocks #rock-1 .container .top {
  background-color: #4a4a4a;
  width: 6vmin;
  height: 5vmin;
  transform-origin: bottom left;
  transform: rotateX(90deg) translateY(2.5vmin) translateZ(5vmin);
}
body .scene .rocks #rock-1 .container .bottom {
  background-color: #4a4a4a;
  width: 6vmin;
  height: 5vmin;
  transform-origin: bottom left;
  transform: rotateX(-90deg) translateY(2.5vmin);
}
body .scene .rocks #rock-1 .container .front {
  background-color: #292929;
  width: 6vmin;
  height: 5vmin;
  transform-origin: bottom left;
  transform: translateZ(2.5vmin);
}
body .scene .rocks #rock-1 .container .back {
  background-color: #292929;
  width: 6vmin;
  height: 5vmin;
  transform-origin: center;
  transform: rotateY(180deg) translateZ(2.5vmin) rotateX(180deg) rotateZ(180deg);
}
body .scene .rocks #rock-2 {
  width: 8vmin;
  height: 4vmin;
  transform: translate3d(15vmin, 1.5vmin, -25vmin) rotateX(-15deg) rotateY(20deg);
}
body .scene .rocks #rock-2 .container {
  position: relative;
  width: 100%;
  height: 100%;
}
body .scene .rocks #rock-2 .container * {
  position: absolute;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
body .scene .rocks #rock-2 .container .left {
  width: 8vmin;
  height: 4vmin;
  background-color: #3D3D3D;
  transform-origin: left top;
  transform: rotateY(-90deg) translateX(-4vmin);
}
body .scene .rocks #rock-2 .container .right {
  width: 8vmin;
  height: 4vmin;
  background-color: #3D3D3D;
  transform-origin: left top;
  transform: rotateY(90deg) translateX(-4vmin) translateZ(8vmin);
}
body .scene .rocks #rock-2 .container .top {
  background-color: #4a4a4a;
  width: 8vmin;
  height: 8vmin;
  transform-origin: bottom left;
  transform: rotateX(90deg) translateY(4vmin) translateZ(4vmin);
}
body .scene .rocks #rock-2 .container .bottom {
  background-color: #4a4a4a;
  width: 8vmin;
  height: 8vmin;
  transform-origin: bottom left;
  transform: rotateX(-90deg) translateY(4vmin);
}
body .scene .rocks #rock-2 .container .front {
  background-color: #292929;
  width: 8vmin;
  height: 4vmin;
  transform-origin: bottom left;
  transform: translateZ(4vmin);
}
body .scene .rocks #rock-2 .container .back {
  background-color: #292929;
  width: 8vmin;
  height: 4vmin;
  transform-origin: center;
  transform: rotateY(180deg) translateZ(4vmin) rotateX(180deg) rotateZ(180deg);
}
body .scene .rocks #rock-3 {
  width: 9vmin;
  height: 4vmin;
  transform: translate3d(15vmin, 2vmin, -25vmin) rotateX(5deg) rotateY(-15deg) rotateZ(3deg);
}
body .scene .rocks #rock-3 .container {
  position: relative;
  width: 100%;
  height: 100%;
}
body .scene .rocks #rock-3 .container * {
  position: absolute;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
body .scene .rocks #rock-3 .container .left {
  width: 8vmin;
  height: 4vmin;
  background-color: #3D3D3D;
  transform-origin: left top;
  transform: rotateY(-90deg) translateX(-4vmin);
}
body .scene .rocks #rock-3 .container .right {
  width: 8vmin;
  height: 4vmin;
  background-color: #3D3D3D;
  transform-origin: left top;
  transform: rotateY(90deg) translateX(-4vmin) translateZ(9vmin);
}
body .scene .rocks #rock-3 .container .top {
  background-color: #4a4a4a;
  width: 9vmin;
  height: 8vmin;
  transform-origin: bottom left;
  transform: rotateX(90deg) translateY(4vmin) translateZ(4vmin);
}
body .scene .rocks #rock-3 .container .bottom {
  background-color: #4a4a4a;
  width: 9vmin;
  height: 8vmin;
  transform-origin: bottom left;
  transform: rotateX(-90deg) translateY(4vmin);
}
body .scene .rocks #rock-3 .container .front {
  background-color: #292929;
  width: 9vmin;
  height: 4vmin;
  transform-origin: bottom left;
  transform: translateZ(4vmin);
}
body .scene .rocks #rock-3 .container .back {
  background-color: #292929;
  width: 9vmin;
  height: 4vmin;
  transform-origin: center;
  transform: rotateY(180deg) translateZ(4vmin) rotateX(180deg) rotateZ(180deg);
}
body .scene .rocks #rock-4 {
  width: 9vmin;
  height: 4vmin;
  transform: translate3d(45vmin, 1.5vmin, 18vmin) rotateX(15deg) rotateY(45deg);
}
body .scene .rocks #rock-4 .container {
  position: relative;
  width: 100%;
  height: 100%;
}
body .scene .rocks #rock-4 .container * {
  position: absolute;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
body .scene .rocks #rock-4 .container .left {
  width: 8vmin;
  height: 4vmin;
  background-color: #3D3D3D;
  transform-origin: left top;
  transform: rotateY(-90deg) translateX(-4vmin);
}
body .scene .rocks #rock-4 .container .right {
  width: 8vmin;
  height: 4vmin;
  background-color: #3D3D3D;
  transform-origin: left top;
  transform: rotateY(90deg) translateX(-4vmin) translateZ(9vmin);
}
body .scene .rocks #rock-4 .container .top {
  background-color: #4a4a4a;
  width: 9vmin;
  height: 8vmin;
  transform-origin: bottom left;
  transform: rotateX(90deg) translateY(4vmin) translateZ(4vmin);
}
body .scene .rocks #rock-4 .container .bottom {
  background-color: #4a4a4a;
  width: 9vmin;
  height: 8vmin;
  transform-origin: bottom left;
  transform: rotateX(-90deg) translateY(4vmin);
}
body .scene .rocks #rock-4 .container .front {
  background-color: #292929;
  width: 9vmin;
  height: 4vmin;
  transform-origin: bottom left;
  transform: translateZ(4vmin);
}
body .scene .rocks #rock-4 .container .back {
  background-color: #292929;
  width: 9vmin;
  height: 4vmin;
  transform-origin: center;
  transform: rotateY(180deg) translateZ(4vmin) rotateX(180deg) rotateZ(180deg);
}
body .scene .rocks #rock-5 {
  width: 12vmin;
  height: 4vmin;
  transform: translate3d(47vmin, 1.5vmin, -22vmin) rotateX(-5deg) rotateY(65deg);
}
body .scene .rocks #rock-5 .container {
  position: relative;
  width: 100%;
  height: 100%;
}
body .scene .rocks #rock-5 .container * {
  position: absolute;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
body .scene .rocks #rock-5 .container .left {
  width: 14vmin;
  height: 4vmin;
  background-color: #3D3D3D;
  transform-origin: left top;
  transform: rotateY(-90deg) translateX(-7vmin);
}
body .scene .rocks #rock-5 .container .right {
  width: 14vmin;
  height: 4vmin;
  background-color: #3D3D3D;
  transform-origin: left top;
  transform: rotateY(90deg) translateX(-7vmin) translateZ(12vmin);
}
body .scene .rocks #rock-5 .container .top {
  background-color: #4a4a4a;
  width: 12vmin;
  height: 14vmin;
  transform-origin: bottom left;
  transform: rotateX(90deg) translateY(7vmin) translateZ(4vmin);
}
body .scene .rocks #rock-5 .container .bottom {
  background-color: #4a4a4a;
  width: 12vmin;
  height: 14vmin;
  transform-origin: bottom left;
  transform: rotateX(-90deg) translateY(7vmin);
}
body .scene .rocks #rock-5 .container .front {
  background-color: #292929;
  width: 12vmin;
  height: 4vmin;
  transform-origin: bottom left;
  transform: translateZ(7vmin);
}
body .scene .rocks #rock-5 .container .back {
  background-color: #292929;
  width: 12vmin;
  height: 4vmin;
  transform-origin: center;
  transform: rotateY(180deg) translateZ(7vmin) rotateX(180deg) rotateZ(180deg);
}
body .scene .jedi {
  position: absolute;
  width: 100%;
  height: 100%;
  bottom: 0;
  transform: translate3d(30vmin, 0, 0);
}
body .scene .jedi .body, body .scene .jedi .head, body .scene .jedi .light-saber, body .scene .jedi .hair, body .scene .jedi .eyes,
body .sc.........完整代码请登录后点击上方下载按钮下载查看

网友评论0