学习套用黑黑萤火虫效果
<style>#papa { margin-left: calc(50% - 720px); margin-top:100px; width: 1280px; height: 741px; display: grid; place-items: center; background: #000 url('https://wx.ttt.dj/updir/6368ffaa2324c.jpg') no-repeat center/cover; box-shadow: 3px 3px 20px #000; perspective: 1000px; overflow: hidden; user-select: none; position: relative; z-index: 1; }
#papa::after { position: absolute; content: '萤火虫--歌手:伊能静'; top: 120px; left:800px; font: bold 2.4em sans-serif; color: gold; text-shadow: 2px 2px 3px #000; opacity: .6; }
#mplayer { position: absolute; bottom: 40px;left: 1050px; ; }
#btnwrap { display: block; fill: hsla(30, 20%, 80%, .9); cursor: pointer; }
#btnwrap:hover { fill: hsla(90, 100%, 100%, .9); }
#tmsg { fill: hsla(30, 100%, 90%, .9); stroke: none; font: bold 1em sans-serif; }
.firefly { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: silver; transform-style: preserve-3d; }
@keyframes move { to { transform: rotate(0) translate3d(0, 0, 0); } }
@keyframes flash { from {opacity: .95; } to { opacity: 1; } }
</style>
<div id="papa">
<svg id="mplayer" width="120" height="120">
<g id="mama" transform="rotate(-90, 60, 60)" style="cursor: pointer;">
<circle id="track" cx="60" cy="60" r="50" fill="none" stroke-width="10" stroke="hsla(60, 20%, 80%, .77)" />
<circle id="prog" cx="60" cy="60" r="50" fill="none" stroke-width="10" stroke="hsla(60,100%,40%,.65)" />
</g>
<g id="btnwrap">
<path id="btnplay" d="M 50 50,50 70,70, 60 z"></path>
<path id="btnpause" d="M 52 50,52 70,57 70,57 50,52 50 z M 60 50,60 70,65 70,65 50,60 50 z" style="display: none;"></path>
<path d="M 57 50,60 50,60 70,57 70 z" fill="transparent" />
</g>
<path id="curPath" d="M 20 70 Q 60 0 100 70" fill="none" stroke="none"/>
<path id="durPath" d="M 20 55 Q 60 110 100 55" fill="none" stroke="none"/>
<g id="tmsg">
<text x="34" y="0"><textPath id="curMsg" xlink:href="#curPath" dominant-baseline="text-after-edge">00:00</textPath></text>
<text x="29" y="0"><textPath id="durMsg" xlink:href="#durPath" dominant-baseline="text-before-edge">00:00</textPath></text>
</g>
</svg>
</div>
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=317221.mp3" loop autoplay></audio>
<script>
(function() {
(function() {for(j=0; j<500; j++) {let ele = document.createElement('span');ele.className = 'firefly';ele.style.cssText += `left: ${Math.random() * 1100}px;top: ${Math.random() * 600}px;background: hsl(${Math.random() * 10 + 50}, ${Math.random() * 50 + 40}%,${Math.random() * 40 + 20}%);box-shadow: 0 0 5px hsla(0,10%,100%,.25);transform: rotate(${Math.random() * 360 + 360}deg) translate3d(${Math.random() * 400 + 100}px,${Math.random() * 300}px,${Math.random() * 1100}px);animation: move 60s infinite ${-10 - Math.random() * 20}s linear;`;papa.appendChild(ele);}})();
let cc = { x: 1*track.getAttribute('cx'), y: 1*track.getAttribute('cy'), len: track.getTotalLength(),};
prog.style.strokeDasharray = prog.style.strokeDashoffset =cc.len;
btnwrap.onclick = () => aud.paused ? aud.play() : aud.pause();
mama.onclick = (e) => {let deg = Math.atan2(e.offsetY - cc.y, e.offsetX - cc.x) * 180 / Math.PI;deg += (e.offsetX < cc.x && e.offsetY < cc.y) ? 450 : 90;aud.currentTime = aud.duration * deg / 360;};
aud.addEventListener('pause', () => mState());
aud.addEventListener('play', () => mState());
aud.addEventListener('seeked', () => aud.play());
aud.addEventListener('timeupdate', () => {prog.style.strokeDashoffset = cc.len - cc.len * aud.currentTime / aud.duration;curMsg.textContent = toMin(aud.currentTime);durMsg.textContent = toMin(aud.duration);});
let mState = () => aud.paused ? (btnplay.style.display = 'block', btnpause.style.display = 'none') : (btnplay.style.display = 'none', btnpause.style.display = 'block');
let toMin = (val)=> {if (!val) return '00:00';val = Math.floor(val);let min = parseInt(val / 60), sec = parseFloat(val % 60);if(min < 10) min = '0' + min;if(sec < 10) sec = '0' + sec;return min + ':' + sec;};
document.title = '萤火虫';
})();
</script>
<br><br><br><br><br> @马黑黑
这次用了eft: calc(50% - 781px);感觉这个也是方便的 萤火虫这个颜色感觉最美,就直接套用了 谢谢黑黑的精彩分享,这个萤火虫效果美极了{:4_199:} 太美了!好逼真:黑夜提着马灯抓荧火虫——小时候做过的事。但小辣椒管理应该没有经历过,现在的年轻人可能没见过马灯,也没有荧火虫来抓了。 寒冬残荷 发表于 2022-11-7 21:08
太美了!好逼真:黑夜提着马灯抓荧火虫——小时候做过的事。但小辣椒管理应该没有经历过,现在的年轻人可能 ...
谢谢寒冬残荷欣赏{:4_173:}
这个灯是没有看见过,但萤火虫知道的 寒冬残荷 发表于 2022-11-7 21:08
太美了!好逼真:黑夜提着马灯抓荧火虫——小时候做过的事。但小辣椒管理应该没有经历过,现在的年轻人可能 ...
主要这个灯没有看见有卖 欣赏音画佳作! 小辣椒 发表于 2022-11-7 21:01
@马黑黑
这次用了eft: calc(50% - 781px);感觉这个也是方便的
记住被减去的数的构成,即计算方式,就很便利的 背景设计的挺好,棒。能够随意控制各元素的物理定位,这对于换了做帖方式的阶段而言,是巨大的进步,想想队长在这方面老师不得要领 马黑黑 发表于 2022-11-7 22:15
记住被减去的数的构成,即计算方式,就很便利的
好的,明白了 相约爱晚亭 发表于 2022-11-7 21:28
欣赏音画佳作!
谢谢欣赏{:4_187:} 小辣椒 发表于 2022-11-7 22:22
好的,明白了
{:4_190:} 马黑黑 发表于 2022-11-7 22:44
黑黑我准备下了,明天见 88 萤火虫效果美极了{:4_199:} 这个帖子的光影设计太棒了,萤火虫的效果也用得好,亲爱的好棒{:4_199:} 我看到萤火虫的年代已经很久远了。 马黑黑 发表于 2022-11-7 22:50
88
黑黑中午好{:4_173:} 风中飞尘 发表于 2022-11-7 22:52
萤火虫效果美极了
谢谢小风欣赏{:4_187:}