|
|

楼主 |
发表于 2022-5-17 07:24
|
显示全部楼层
代码分享:- <style>
- .bgBox {
- position: relative;
- display: flex;
- justify-content: center;
- align-items: center;
- width: 1280px;
- height: 768px;
- left: -342px;
- background: #000 url('https://638183.freep.cn/638183/t22/51/laomiao.jpg') no-repeat;
- overflow: hidden;
- perspective: 3000px;
- }
- .ball {
- position: absolute;
- width: 24px;
- height: 24px;
- border-radius: 50%;
- display: block;
- transform-style: preserve-3d;
- animation: fly var(--ss) linear infinite alternate;
- }
- .ball::before, .ball::after {
- position: absolute;
- content: '';
- width: 24px;
- height: 24px;
- border-radius: 50%;
- left: -10px;
- top: 5px;
- background: green;
- animation: fly calc(var(--ss) + 1s) linear infinite;
- }
- .ball::after {
- background: red;
- animation: fly calc(var(--ss) + 2s) linear infinite;
- }
- @keyframes fly {
- 0% { transform: translate3d(0, 0, 0) scale(0.6); opacity: 0; }
- 50% { opacity: .6; }
- 100% { transform: translate3d(var(--tx), var(--ty), var(--tz)); opacity: 0; }
- }
- </style>
- <div class="bgBox"></div>
- <script>
- let bgBox = document.querySelector('.bgBox');
- let total = 200;
- let sStr = '';
- for(j=0; j<total; j++){
- let ww = getNum(20,30);
- let bg = `background: linear-gradient(120deg, ${setRgb()}, ${setRgb()}`;
- let xx = getNum(-640,640);
- let yy = getNum(-384,384) ;
- sStr += `<span class='ball' style='--ss: ${getNum(4,10)}s; --tx: ${xx}px; --ty:${yy}px; --tz: ${getNum(10,100)}px; width: ${ww}px; height: ${ww}px; ${bg}'></span>`;
- }
- bgBox.innerHTML += sStr;
- let aud = document.createElement('iframe');
- aud.src = 'https://music.163.com/outchain/player?type=2&id=1927765047&auto=1&height=66';
- aud.style.display = 'none';
- bgBox.appendChild(aud);
- function setRgb(){ return `rgba(${getNum(0,255)},${getNum(0,255)}, ${getNum(0,255)})`; }
- function getNum(min,max){ return Math.floor(Math.random()*(max-min+1))+min; }
- </script>
复制代码
|
评分
-
| 参与人数 1 | 威望 +50 |
金钱 +100 |
经验 +50 |
收起
理由
|
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|