|
|

楼主 |
发表于 2023-4-16 21:44
|
显示全部楼层
代码
- <style>
- #papa {
- margin: 20px auto;
- width: 740px;
- height: 640px;
- background: #000;
- overflow: hidden;
- position: relative;
- }
- #wrap {
- position: absolute;
- width: 100%;
- height: 50%;
- transform: rotate(45deg);
- }
- .line {
- --du: 10s; --delay: 0s;
- position: absolute;
- width: 1px;
- height: 100px;
- top: -200px;
- opacity: .9;
- background: linear-gradient(to top, snow, transparent);
- animation: flow var(--du) var(--delay) infinite linear;
- }
- @keyframes flow { to { top: 100%; opacity: 0; } }
- </style>
- <div id="papa">
- <div id="wrap"></div>
- </div>
- <script>
- let total = 40, ww = wrap.offsetWidth;
- Array.from({length:total}).forEach((item,key) => {
- let sp = document.createElement('span');
- sp.className = 'line';
- sp.style.cssText += `
- --delay: ${Math.random() * 4 - 4}s;
- --du: ${Math.random() * 8 + 4}s;
- left: ${Math.random() * ww}px;
- height: ${Math.random() * 50 + 50}px;
- `;
- wrap.appendChild(sp);
- });
- </script>
复制代码
|
|