div+css实现旋转的楼梯动画代码
代码语言:html
所属分类:动画
代码描述:div+css实现旋转的楼梯动画代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
* {
transform-style: preserve-3d;
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
perspective: 1000vmin;
background: radial-gradient( circle at 50% 52.5%, #000000, #363636);
}
.content {
width: 80vmin;
height: 80vmin;
transform: rotateX(-10deg) translateY(-15vmin) scale3d(0.85, 0.5, 1.5);
}
.cuboid {
--height: 8;
--width: 80;
--depth: 50;
--hue: 200;
--sat: 75%;
height: calc(var(--height) * 1vmin);
width: calc(var(--width) * 1vmin);
position: absolute;
transform: translate3d(0vmin, 0vmin, 0vmin);
}
.cuboid .side {
position: absolute;
top: 50%;
left: 50%;
height: 100%;
width: 100%;
border-radius: 2px;
}
.cuboid .side:nth-of-type(1) {
transform: translate3d(-50%, -50%, calc(var(--depth) * 0.5vmin));
background: hsl(var(--hue), var(--sat), 60%);
}
.cuboid .side:nth-of-type(2) {
transform: translate3d(-50%, -50%, calc(var(--depth) * -0.5vmin))
rotateY(180deg);
background: hsl(var(--hue), var(--sat), 25%);
}
.cuboid .side:nth-of-type(3) {
width: calc(var(--depth) * 1vmin);
transform: translate(-50%, -50%) rotateY(90deg)
translate3d(0, 0, calc(var(--width) * 0.5vmin));
background: hsl(var(--hue), var(--sat), 75%);
}
.cuboid .side:nth-of-type(4) {
width: calc(var(--depth) * 1vmin);
transform: translate(-50%, -50%) rotateY(-90deg)
translate3d(0, 0, calc(var(--width) * 0.5vmin));
background: hsl(var(--hue), var(--sat), 40%);
}
.cuboid .side:nth-of-type(5) {
height: calc(var(--depth) * 1vmin);
transform: translate(-50%, -50%) rotateX(90deg)
translate3d(0, 0, calc(var(--height) * 0.5vmin));
background: hsl(var(--hue), var(--sat), 75%);
}
.cuboid .side:nth-of-type(6) {
height: calc(var(--depth) * 1vmin);
transform: translate(-50%, -50%) rotateX(-90deg)
translate3d(0, 0, calc(var(--height) * 0.5vmin));
background: hsl(var(--hue), var(--sat), 20%);
}
.cuboid:nth-child(2) {
top: 8vmin;
--hue: 236;
transform: translateZ(10vmin);
}
.cuboid:nth-child(3) {
top: 16vmin;
--hue: 272;
transform: translateZ(20vmin);
}
.cuboid:nth-child(4) {
top: 24vmin;
--hue: 308;
transform: translateZ(30vmin);
}
.cuboid:nth-child(5) {
top: 32vmin;
--hue: 344;
transform: translateZ(40vmin);
}
.cuboid:nth-child(6) {
top: 40vmin;
--hue: 20;
transform: translateZ(50vmin);
}
.cuboid:nth-child(7) {
top: 48vmin;
--hue: 56;
transform: translateZ(60vmin);
}
.cuboid:nth-child(8) {
top: 56vmin;
--hue: 92;
transform: translateZ(70vmin);
}
.cuboid:nth-child(9) {
top: 64vmin;
--hue: 128;
transform: translateZ(80vmin);
}
.cuboid:nth-child(10) {
top: 72vmin;
--hue: 164;
transform: translateZ(90vmin);
}
.cuboid:nth-child(2) .cuboid {
--hue: 236;
animation-delay: -0.25s;
}
.cuboid:nth-child(3) .cuboid {
--hue: 272;
animation-delay: -0.5s;
}
.cuboid:nth-child(4) .cuboid {
--hue: 308;
animation-delay: -0.75s;
}
.cuboid:nth-child(5) .cuboid {
--hue: 344;
animation-delay: -1s;
}
.cuboid:nth-child(6) .cuboid {
--hue: 20;
animation-delay: -1.25s;
}
.cuboid:nth-child(7) .cuboid {
--hue: 56;
animation-delay: -1.5s;
}
.cuboid:nth-child(8) .cuboid {
--hue: 92;
animation-delay: -1.75s;
}
.cuboid:nth-child(9) .cuboid {
--hue: 128;
animation-delay: -2s;
}
.cuboid:nth-child(10) .cuboid {
--hue: 164;
animation-delay: -2.25s;
}
.cuboid .cuboid {
--width: 20;
--depth: 20;
--height: 8;
transform: translate3d(40vmin, 0, -15vmin) rotateY(-135deg);
animation: move 4s ease 0s infinite;
}
@keyframes move {
50% { transform: translate3d(40vmin, 0vmin, -65vmin) rotateY(-135deg); }
}
.cuboid .........完整代码请登录后点击上方下载按钮下载查看
网友评论0