|
|

楼主 |
发表于 2022-4-26 21:59
|
显示全部楼层
本帖最后由 马黑黑 于 2022-4-26 22:04 编辑
再远基础上略作改动,其实可以改的地方还很多:
- <style>
- body { perspective: 3000px; }
- .mBox {
- --w: 100px;
- margin: auto;
- margin-top: 100px;
- display: flex;
- justify-content: center;
- align-items: center;
- width: var(--w);
- height: var(--w);
- cursor: pointer;
- position: relative;
- animation: rot 2s linear infinite;
- }
- .zBox {
- position: absolute;
- display: block;
- border-style: dotted;
- border-width: 1px;
- border-color: transparent red transparent magenta;
- border-radius: 50%;
- }
- @keyframes rot { to { transform: rotate(1turn); } }
- </style>
- <div class="mBox"></div>
- <script>
- let flag = true;
- let ele = document.querySelector(".mBox");
- let len= ele.clientWidth;
- let zStr = "";
- let all = 100;
- let angle = Math.floor(360 / all);
- for(j=0; j< all; j++){
- let wh =Math.floor(len- j * (len / all));
- zStr += `<span class="zBox" style="transform: rotate(${j*angle}deg);width: ${wh}px; height: ${wh}px"></span>\n`;
- }
- ele.innerHTML += zStr;
- let au = document.createElement("audio");
- au.src= "http://www.kumeiwp.com/sub/filestores/2022/04/26/884887672b95a12a17efbf911f4765f4.mp3";
- au.loop = true;
- au.autoplay = flag;
- au.style.display = "none";
- ele.appendChild(au);
- if(!flag) ele.style.animationPlayState = "paused";
- ele.onclick = function(){
- flag ? (au.pause(),this.style.animationPlayState = "paused",flag = false) : (au.play(),this.style.animationPlayState = "running",flag = true);
- }
- </script>
复制代码
|
|