|
|

楼主 |
发表于 2025-7-29 22:44
|
显示全部楼层
代码
- <style>
- #pa {
- margin: 20px auto;
- width: 750px;
- height: 600px;
- display: grid;
- place-items: center;
- position: relative;
- }
- #ma {
- position: absolute;
- width: 398px;
- height: 398px;
- transform: scale(1);
- }
- #ma:hover .son {
- transform: unset;
- }
- .son {
- --angle: 0;
- position: absolute;
- background: url('https://638183.freep.cn/638183/small/fi1.webp') no-repeat var(--x1) var(--y1);
- transform: rotate(var(--angle)) translate(160px);
- transition: 2s;
- }
- </style>
- <div id="pa">
- <div id="ma"></div>
- </div>
- <script>
- const rows = 8, cols = 8, size = 398;
- const ww = size / cols, hh = size / rows;
- for (let j = 0; j < rows; j ++) {
- for (let k = 0; k < cols; k ++) {
- const son = document.createElement('div');
- son.className = 'son';
- son.style.cssText += `
- width: ${ww}px;
- height: ${hh}px;
- left: ${k * ww}px;
- top: ${j * hh}px;
- --x1: ${-1 * k * ww}px;
- --y1: ${-1 * j * hh}px;
- --angle: ${360 * Math.random()}deg;
- `;
- ma.appendChild(son);
- }
- }
- </script>
复制代码
|
评分
-
| 参与人数 1 | 威望 +50 |
金钱 +100 |
经验 +50 |
收起
理由
|
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|