|
|

楼主 |
发表于 2025-7-8 12:10
|
显示全部楼层
代码:
- <style>
- #papa { margin: 20px auto; width: 1024px; height: 640px; border: 1px solid gray; perspective: 3000px; transform-style: preserve-3d; overflow: visible; display: grid; place-items: center; position: relative; }
- .son { position: absolute; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(35deg, green, skyblue); filter: drop-shadow(2px 4px 8px gray); opacity: 0; transform: rotateZ(var(--a)) translate3d(var(--x), var(--y), var(--z)); --x: 0; --y: 0; --z: 0; --a: 0; }
- </style>
- <div id="papa"></div>
- <script type="module">
- import TWEEN from 'https://638183.freep.cn/638183/3dev/examples/jsm/libs/tween.module.js';
- const total = 60, sons = [];
- Array.from({length: total}).forEach(son => {
- son = document.createElement('div');
- son.className = 'son';
- son.style.background = `
- linear-gradient(
- 35deg,
- #${Math.random().toString(16).substring(2, 8)},
- #${Math.random().toString(16).substring(2, 8)}
- )
- `;
- sons.push(son);
- papa.appendChild(son);
- const begin = {
- x: papa.clientWidth / 4 - Math.random() * papa.clientWidth / 2,
- y: papa.clientHeight / 4 - Math.random() * papa.clientHeight / 2,
- z: -5000,
- a: 0
- };
- const end = {
- x: 0,
- y: [-papa.clientHeight / 1.5, papa.clientHeight / 3],
- z: [-2000, 600],
- a: [60 - Math.random() * 120, 80 - Math.random() * 160]
- };
- const tween = new TWEEN.Tween(begin)
- .to(end, Math.random() * 5000 + 8000)
- .onUpdate( () => {
- son.style.setProperty('--x', begin.x + 'px');
- son.style.setProperty('--y', begin.y + 'px');
- son.style.setProperty('--z', begin.z + 'px');
- son.style.setProperty('--a', begin.a + 'deg');
- })
- .onStart( () => son.style.opacity = '1')
- .delay(Math.random() * 5000)
- .repeat(Infinity)
- .repeatDelay(Math.random() * 5000)
- .easing(TWEEN.Easing.Exponential.Out)
- .yoyo(Math.random() * 10000)
- .start();
- });
- const animate = () => {
- requestAnimationFrame(animate);
- TWEEN.update();
- };
- animate();
- </script>
复制代码
|
评分
-
| 参与人数 1 | 威望 +50 |
金钱 +100 |
经验 +50 |
收起
理由
|
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|