|
|

楼主 |
发表于 2022-7-4 13:48
|
显示全部楼层
代码分享
- <style>
- #ma { left: -242px; width: 1080px; height: 608px; background: #000 url('https://638183.freep.cn/638183/t22/hl/jj.jpeg') no-repeat; perspective: 1000px; box-shadow: 2px 2px 20px #000; position: relative; }
- #circle { position: absolute; width: 100px; height: 100px; top: 10px; right: 10px; border-radius: 50%; background: red linear-gradient(120deg, lightgreen, transparent); mask-image: radial-gradient(circle at 30% 30%,transparent 20%, red); -webkit-mask-image: radial-gradient(circle at 30% 30%,transparent 20%, red); cursor: pointer; z-index: 100; }
- #ma input { border: none; outline: none; opacity: .75; cursor: pointer; }
- #ma p { margin: 0; padding: 0; }
- #playbox { position: absolute; left: 10px; bottom: 10px; padding: 10px; font: normal 1em sans-serif; color: tomato; text-shadow: 1px 1px 1px #000; background: transparent; border-radius: 8px; overflow: hidden; box-shadow: 1px 1px 2px rgba(0,0,0,.15); z-index: 100; }
- #playbox::before { position: absolute; content: ''; margin: -20px; left: 0; top: 0; right: 0; bottom: 0; background: rgba(255,255,255,.45); filter: blur(2px); z-index: -1; }
- #btnplay { width: 30px; height: 30px; border-radius: 50%; }
- #btnplay:hover { background: #aaa; color: #ff0000; }
- .pics {position: absolute; width: 256px; box-shadow: inherit; transform-style: preserve-3d; display: none; opacity: .65; transition: all .5s; }
- .pics:hover { width: 300px; opacity: 1; cursor: pointer; }
- @keyframes drop { from { transform: translateY(10px); } to { transform: translateY(488px); } }
- @keyframes up { from { transform: translateY(488px); } to { transform: translateY(10px); } }
- </style>
- <div id="ma">
- <div id="circle"></div>
- <div id="playbox">
- <p id="geci" style="font-size: 1.2em">纯音乐 - 夏雨风荷</p>
- <p style="display: flex; align-items: center; gap: 4px; margin-top: 10px;">
- <input id="btnplay" type="button" value=">" />
- <input id="slider" type="range" min="0" max="100" value="0" />
- <span id="per">0%</span>
- </p>
- </div>
- </div>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=29437826.mp3" autoplay="autoplay" loop="loop"></audio>
- <script>
- let flag = 1;
- let imgAr =[2,3,4,5,6];
- let gnum = (min,max) => Math.floor(Math.random()*(max-min+1))+min;
- imgAr.forEach((item,key) => {
- item = document.createElement('img');
- item.className = 'pics';
- item.src = 'https://638183.freep.cn/638183/t22/hl/jj' + imgAr[key] + '.jpg';
- item.style.left = key * 190 + 30 + 'px';
- item.style.top = gnum(40, 200) + 'px';
- item.style.transform = 'rotateY(' + gnum(25,45) +'deg)';
- item.alt = '';
- ma.appendChild(item);
- });
- circle.onmouseover = () => {
- let pics = document.querySelectorAll('.pics')
- if(flag == 1) {
- circle.style.animation = 'drop .5s forwards ease-in',
- pics.forEach((ele) => ele.style.display = 'block');
- flag = 0;
- } else {
- circle.style.animation = 'up .5s forwards ease-out';
- pics.forEach((ele) => ele.style.display = 'none');
- flag = 1;
- }
- }
- slider.onmousedown = () => aud.pause();
- slider.onchange = () => { aud.currentTime = slider.value * aud.duration / 100; aud.play(); }
- btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
- aud.addEventListener('playing', () => btnplay.value = '||');
- aud.addEventListener('pause', () => btnplay.value = '>');
- aud.addEventListener('timeupdate', () => {
- let prog = 100 * aud.currentTime / aud.duration;
- slider.value = prog;
- per.innerText = toMin(aud.currentTime) + ' | ' + toMin(aud.duration);
- });
- let toMin = (sec) => {
- if(!sec) return '0:00';
- sec = parseInt(sec);
- return parseInt(sec / 60) + ':' + parseFloat(sec % 60).toString().padStart(2,'0');
- }
- </script>
复制代码
|
评分
-
| 参与人数 1 | 威望 +30 |
金钱 +60 |
经验 +30 |
收起
理由
|
加林森
| + 30 |
+ 60 |
+ 30 |
很给力! |
查看全部评分
|