|
|

楼主 |
发表于 2022-7-10 07:35
|
显示全部楼层
代码分享:
- <style>
- #papa { left: -352px; width: 1300px; height: 758px; background: blue url('/data/attachment/forum/202207/09/234557wxn4kww7edc37aac.jpg') no-repeat center/cover; box-shadow: 4px 4px 24px #000; position: relative; }
- #hunter { position: absolute; width: 122px; height: 147px; transition: all 3s; z-index: 99; }
- #prey { position: absolute; width: 240px; height: 240px; border-radius: 50%; }
- #btnplay { position: absolute;left: 20px; top: 20px; width: 30px; height: 30px; cursor: pointer; border: none; outline: none; border-radius: 50%; }
- #btnplay:hover { color: red; box-shadow: 1px 1px 1px #000; }
- #lrcbox { position: absolute;left: 60px;top: 20px;font: normal 1.2em / 1.6em '宋体', sans-serif;color: snow;text-shadow: 1px 1px 2px #000; }
- </style>
- <div id="papa">
- <input id="btnplay" type="button" value=">" />
- <div id="lrcbox">LRC LOADING ...</div>
- <img id="hunter" alt="" src="/data/attachment/forum/202207/10/071610mpel9l0n9nzdg4z5.gif" />
- <img id="prey" src="/data/attachment/forum/202207/09/234428pscd33mrersth4gx.gif" alt="" />
- </div>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=1404387331.mp3" autoplay="autoplay" loop="loop"></audio>
- <script>
- let lrcAr = [
- ['0.00','曲名 : 红尘客(伴奏)'],
- ['5.00','歌手 : 夸父'],
- ['10.00','帖名 : 追随 - 致朵拉'],
- ['160.00','感谢欣赏 祝你好运']
- ];
- let num = (min, max) => Math.floor(Math.random() * (max-min+1)) + min;
- setTimeout(gogo,100);
- btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
- aud.addEventListener('playing', () => btnplay.value = '||');
- aud.addEventListener('pause', () => btnplay.value = '>');
- aud.addEventListener('timeupdate',function(){
- let tt = aud.currentTime;
- for(j=0; j<lrcAr.length; j++){
- if(tt >= lrcAr[j][0]) lrcbox.innerHTML = lrcAr[j][1];
- }
- });
- function gogo() {
- let left = num(50,1050), top = num(420,518);
- prey.style.left = left + 'px';
- prey.style.top = top + 'px';
- hunter.style.left = left + 45 + 'px';
- hunter.style.top = top - 100 + 'px';
- setTimeout(gogo,6000);
- }
- </script>
复制代码
|
|