林俊杰 - 杀手 TO:墨羽
本帖最后由 宁静 于 2023-2-24 00:02 编辑 <br /><br /><style>#papa { margin: 0px auto 0; width: 1327px; height: 784px;top: 150px;left: -220px; position: relative; background: #ccc url('https://pic.imgdb.cn/item/62d1aaa1f54cd3f937ef5444.jpg') no-repeat;box-shadow: 0px 4px 20px #000; }
#gun { position: absolute; right: 0;top:85px; width: 81px; height: 63px;left: 1000px; transition: .06s; cursor: pointer; }
.bullet { position: absolute; width: 10px; height: 10px; left: 300px;; top: 230px; border-radius: 50%; background: linear-gradient(120deg), white,green; }
#papa input { border: none; outline: none; opacity: .75; cursor: pointer; }
#papa p { margin: 0; padding: 0; }
.playbox { position: absolute; left: 480px; top: 330px; padding: 10px; font: normal 1em sans-serif; color: #eee; background: rgba(255,255,255,.2); border-radius: 8px; backdrop-filter: blur(1px); overflow: hidden; box-shadow: 1px 1px 2px rgba(0,0,0,.15); z-index: 100; }
#btnplay { width: 30px; height: 30px; border-radius: 50%; }
#btnplay:hover { background: #aaa; color: #ff0000; }
@keyframes shot { to { left: var(--ll); top: var(--tt); } }
</style>
<div id="papa">
<img id="gun" alt="" src="https://pic.imgdb.cn/item/62d1aac6f54cd3f937ef7cc7.png" />
<div id="ball"></div>
<div class="playbox">
<p id="geci" style="font-size: 1.2em; text-shadow: 1px 1px 1px #222">LRC Loading ... </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="gunAud" src="https://img.tukuppt.com/newpreview_music/08/98/68/5c88af299e50946800.mp3"></audio>
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=26305538.mp3" autoplay="autoplay" loop="loop"></audio>
<script>
let total = 10; //子弹数
let lrcAr = [ ['0.00','林俊杰 - 杀手'], ['78.30','感谢欣赏'] ];
let num = (min, max) => Math.floor(Math.random() * (max-min+1)) + min;
gunAud.playbackRate = 3;
gun.onmousedown = () => {
gun.style.transform = 'rotate(4deg)';
gunAud.pause();
}
gun.onmouseup = () => {
gun.style.transform = 'rotate(0)';
gunAud.play();
let bullets = document.querySelectorAll('.bullet');
if(bullets.length >= total) papa.removeChild(bullets);
let bullet = document.createElement('span');
bullet.className = 'bullet';
bullet.style.cssText = `
--tt: ${num(280,340)}px; --ll: ${num(20,80)}px;
background: linear-gradient(120deg, rgb(${num(0,255)},${num(0,255)},${num(0,255)}), rgb(${num(0,255)},${num(0,255)},${num(0,255)}));
animation: shot .4s linear forwards;`
papa.appendChild(bullet);
}
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);
for(j=0; j<lrcAr.length; j++){
if(aud.currentTime >= lrcAr) geci.innerHTML = lrcAr;
}
});
let toMin = (val) => {
if(!val) return '0:0';
val = Math.floor(val);
return parseInt(val / 60) + ':' +parseFloat(val % 60);
}
</script>
<br><br><br><br><br><br><br><br><br><br> @墨羽
大心脏,快来看看,看你往哪里逃 这个是趣味帖,也是可以说是技术帖,纯css js 制作 手机也可以欣赏的播放器,制作太棒啦~
跑来欣赏 鼠标点击上面手枪,子弹会出来,一次10颗子弹,停顿后继续可以打枪 宁静 发表于 2022-7-22 21:34
这个是趣味帖,也是可以说是技术帖,纯css js 制作
绝对的技术贴
之前也认识一个坛友,会制作CSS代码的,
我也跟着学了点皮毛的三分之一,现在又忘光了{:9001:}
哈哈,好玩,我打出20多枪就下老实了吧{:9001:} 宁静这招厉害,哈哈 瞳萤 发表于 2022-7-22 21:34
手机也可以欣赏的播放器,制作太棒啦~
谢谢~~手枪不是播放器,是可以打出子弹{:9001:}