|
|

楼主 |
发表于 2022-4-10 20:34
|
显示全部楼层
代码:
- <style>
- body { perspective: 3000px; }
- .cube {
- --x: 120px;
- --xx: -60px;
- margin: 100px auto;
- width: var(--x);
- height: var(--x);
- transform-style: preserve-3d;
- transform-origin: 50% 50% 0;
- animation: rot 10s linear infinite;
- }
- .cube div {
- position: absolute;
- left: 0; top: 0; width: inherit; height: inherit;
- font: 2em / var(--x) Arial;
- color: white;
- text-align: center;
- text-shadow: 1px 1px 2px #000;
- opacity: .85;
- }
- .cube div:nth-child(1) { background: tan; transform: rotateY(0deg) translateZ(calc(var(--x) / 2)); }
- .cube div:nth-child(2) { background: black; transform: rotateY(90deg) translateZ(calc(var(--x) / 2)); }
- .cube div:nth-child(3) { background: green; transform: rotateY(180deg) translateZ(calc(var(--x) / 2)); }
- .cube div:nth-child(4) { background: magenta; transform: rotateY(270deg) translateZ(calc(var(--x) / 2)); }
- .cube div:nth-child(5) { background: red; transform: rotateX(-90deg) translateZ(calc(var(--x) / 2)); }
- .cube div:nth-child(6) {background: green; transform: rotateX(-90deg) translateZ(var(--xx)); }
- @keyframes rot {
- to { transform: rotateX(-720deg) rotateY(360deg); }
- }
- </style>
- <div class="cube">
- <div>前</div>
- <div>左</div>
- <div>后</div>
- <div>右</div>
- <div>底</div>
- <div>顶</div>
- </div>
复制代码
|
|