- A+
所属分类:Web前端
搭建舞台
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style type="text/css"> html, body { width: 100%; height: 100%; background-color: #000; overflow: hidden; } /* 设置视距1000px 子元素在3D中变换 */ .preserve { transform-style: preserve-3d; perspective: 1000px; } /* 容器 */ .container { position: relative; margin-top: 10vh; text-align: center; /* animation: rotateReverse 10s infinite linear; */ } /* 舞台 */ .stage { transform: rotateX(10deg) rotateZ(0); /* animation: rotate 10s infinite linear; */ } /* 数字样式 */ .number { position: relative; width: 3vw; height: 12vw; display: inline-block; margin: 3vw 3vw 0 0; } .line { position: absolute; top: 0; left: 0; width: 3vw; height: 2px; background: #181919; } .line::before, .line::after { content: ""; position: absolute; top: 0; width: 50%; height: 100%; background-color: #34eabc; box-shadow: 0 0 1vw #0bfdfd, inset 0 0 0.125vmin #0bfdfd; } .line::before { left: 0; transition: all 0.5s ease-in; } .line::after { right: 0; transition: all 0.5s ease-out; } /* 计算每根线的位置 */ .line:nth-child(1) { top: -0.2vw; } .line:nth-child(2) { top: 3.2vw; } .line:nth-child(3) { top: 6.6vw; } .line:nth-child(4) { transform: rotate(90deg) translateY(0.2vw); /* 设置 旋转中心为 最左边 元素中点 */ transform-origin: 0 center; } .line:nth-child(5) { transform: rotate(-90deg) translateY(0.2vw); /* 设置 旋转中心为 最右边 元素中点 */ transform-origin: 100% center; } .line:nth-child(6) { top: 3.4vw; transform: rotate(90deg) translateY(0.2vw); transform-origin: 0 center; } .line:nth-child(7) { top: 3.4vw; transform: rotate(-90deg) translateY(0.2vw); transform-origin: 100% center; } /* 减少我们的距离 实现阴影效果 */ .translate::before, .translate::after { transform: translateZ(50px); } </style> </head> <body> <div class="container preserve"> <div class="stage preserve"> <div class="number preserve"> <div class="line preserve translate"></div> <div class="line preserve translate"></div> <div class="line preserve translate"></div> <div class="line preserve translate"></div> <div class="line preserve translate"></div> <div class="line preserve translate"></div> <div class="line preserve translate">