霜叶红于二月花(黑黑代码)
<style>#papa { margin-left: calc(50% - 781px); margin-top:100px; width: 1400px; height: 800px; display: grid; place-items: center; background: #000 url('https://pic.imgdb.cn/item/64b7e1e01ddac507cc7ca3eb.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: '2023、7.19 东篱闲人'; top: 40px; font: bold 1.1em sans-serif; color: gold; text-shadow: 1px 1px 2px #000; opacity: .6; }
#mplayer { position: absolute; bottom: 20px; z-index: 1000; }
#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=1384127698.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() * 1000}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> 这些小点点放在这帖里也漂亮。欣赏东篱大哥好帖{:4_199:} 居中好像有点问题,东篱大哥1400宽的帖子,应该是calc(50% - 781px); 东篱大哥厉害,现在套用什么代码都是直接成功呢。有东篱大哥的制图效果还有黑黑的代码加持,让帖子更漂亮了{:4_199:} 红影 发表于 2023-7-19 22:01
居中好像有点问题,东篱大哥1400宽的帖子,应该是calc(50% - 781px);
整不明白。。。{:5_103:} 思呀,念呀,想呀,忆呀,都装裱起来,精致而美 东篱闲人 发表于 2023-7-19 22:12
整不明白。。。
那个值用宽度一半加上81,你的是原帖里的681,现在你帖子1400宽,所以应该用781就居中了啊。这个是黑黑教的{:4_173:} 景儿美,影儿美{:4_173:} 红影 发表于 2023-7-19 23:34
那个值用宽度一半加上81,你的是原帖里的681,现在你帖子1400宽,所以应该用781就居中了啊。这个是黑黑教 ...
好方法。。。{:5_116:} 马黑黑 发表于 2023-7-19 22:18
思呀,念呀,想呀,忆呀,都装裱起来,精致而美
那装吧。。。 红影 发表于 2023-7-19 23:34
那个值用宽度一半加上81,你的是原帖里的681,现在你帖子1400宽,所以应该用781就居中了啊。这个是黑黑教 ...
我这里看是居中的。。 樵歌 发表于 2023-7-20 07:09
景儿美,影儿美
你也美。。。{:5_116:} 东篱闲人 发表于 2023-7-20 09:38
那装吧。。。
我见到你再装 东篱闲人 发表于 2023-7-20 09:38
好方法。。。
呵呵,不是我的方法,是黑黑教的{:4_173:} 东篱闲人 发表于 2023-7-20 09:39
我这里看是居中的。。
没有啊,偏右了。 红影 发表于 2023-7-20 14:05
没有啊,偏右了。
用你那方法调一下,挺管用的,。。。{:5_106:} 东篱闲人 发表于 2023-7-20 21:00
用你那方法调一下,挺管用的,。。。
这是黑黑的方法啊,嗯,现在居中了{:4_199:} 红影 发表于 2023-7-20 21:09
这是黑黑的方法啊,嗯,现在居中了
{:5_108:}{:4_180:} 东篱闲人 发表于 2023-7-20 21:37
下回都可以用这样的法子居中了。{:4_204:} 红影 发表于 2023-7-20 21:42
下回都可以用这样的法子居中了。
嗯嗯,又学一招。。。。{:5_112:}
页:
[1]
2