|
|

楼主 |
发表于 2022-5-2 23:38
|
显示全部楼层
本帖最后由 马黑黑 于 2022-5-2 23:42 编辑
代码:
- <style>
- .wrap {
- margin: auto; margin-top: 100px;
- width: 300px;
- height: 300px;
- perspective: 1800px;
- position: relative;
- animation: rot 10s linear infinite;
- }
- .flower {
- width: 50%;
- height: 50%;
- border-radius: 0 100%;
- background-color: #ccc;
- opacity: .85;
- transform-origin: 100% 100%;
- transform-style: preserve-3d;
- position: absolute;
- }
- @keyframes rot { to { transform: rotate(1turn); } }
- </style>
- <div class="wrap"></div>
- <script>
- let wrap = document.querySelector('.wrap');
- let flag = true;
- let str = '';
- for(j=0; j< 5; j++) {
- str += `<div class='flower' style='background: linear-gradient(${getColor()}, ${getColor()}); transform: rotate(${72*j}deg)'></div>`;
- }
- wrap.innerHTML = str;
- let au = document.createElement('audio');
- au.src = "http://www.kumeiwp.com/sub/filestores/2022/04/16/4dc3020a14f7266fc4ffde61e56e0d79.mp3";
- au.autoplay = flag;
- au.loop = true;
- au.style.display = 'none';
- wrap.appendChild(au);
- let tt = setInterval(setColor, 1000);
- wrap.onclick = function(){
- flag ? (au.pause(), this.style.animationPlayState = 'paused', flag = false) : (au.play(), this.style.animationPlayState = 'running', flag = true);
- }
- function setColor(){
- let petal = document.querySelectorAll('.flower');
- for(j=0; j< petal.length; j++){
- petal[j].style.background = `linear-gradient(${getColor()},${getColor()})`;
- }
- }
- function getColor(){
- return `#${Math.random().toString(16).substr(-6)}`;
- }
- </script>
复制代码
|
评分
-
| 参与人数 2 | 威望 +80 |
金钱 +160 |
经验 +80 |
收起
理由
|
千羽
| + 30 |
+ 60 |
+ 30 |
赞一个! |
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|