马黑黑 发表于 2023-7-18 07:27

Beyond - 无尽空虚

<style>
#mydiv { margin: -80px 0 0 calc(50% - 681px); width: 1200px; height: 675px; background: #cc8c70 url('https://638183.freep.cn/638183/t23/2/wjkx.jpg') no-repeat center/cover; box-shadow: 0 0 8px 0 #000; opacity: .95; overflow: hidden; z-index: 1; position: relative; --state: paused; }
#mydiv::before, #mydiv::after { position: absolute; content: '\1F982'; font-size: 60px; bottom: 15px; left: 40%; }
#mydiv::after { content: '\1FAB2'; transform: translateY(15px) rotate(-10deg); font-size: 40px; }
#lrc { position: absolute; top: 10px; left: 50%; transform: translate(-50%); font: bold 2.4em sans-serif; color: rgb(240,240,240); -webkit-background-clip: text; filter: drop-shadow(1px 1px 2px rgba(0,0,0,.95)); --motion: cover2; --tt: 5s; }
#lrc::before { position: absolute; content: attr(data-lrc); width: 20%; height: 100%; color: transparent; overflow: hidden; white-space: nowrap; background: linear-gradient(180deg,rgba(112,145,180,.45),rgba(86,145,250,.75)); filter: inherit; -webkit-background-clip: text; animation: var(--motion) var(--tt) linear forwards var(--state); }
pinpu-wrapper { position: absolute; bottom: 80px; left: 285px; cursor: pointer; }
pin-pu { position: absolute; bottom: 0; animation: pinpuMotion var(--du) var(--delay) infinite alternate linear var(--state); --psw: 6px; }
pin-pu::before { content: ''; position: absolute; left: calc(50% - var(--psw) / 2); width: var(--psw); height: var(--psw); border-radius: 50%; background: snow; }
.mybox { position: absolute; top: -100px; left: 80%; font-size: 50px; animation: down 8s var(--delay) infinite linear var(--state); --delay: 0s; --deg: 5deg; }
.mybox:nth-of-type(2) { --delay: -2s; --deg: -5deg; }
.mybox:nth-of-type(3) { --delay: -4s; --deg: -15deg; }
.mybox:nth-of-type(4) { --delay: -6s; --deg: -15deg; }
@keyframes pinpuMotion { from { height: 0px; } to { height: var(--height); } }
@keyframes down { to { transform: rotate(var(--deg)) translateY(800px) rotate(360deg); } }
@keyframes cover1 { from { width: 0; } to { width: 100%; } }
@keyframes cover2 { from { width: 0; } to { width: 100%; } }
</style>

<div id="mydiv">
    <span class="mybox">&#129718;</span>
    <span class="mybox">&#129718;</span>
    <span class="mybox">&#129718;</span>
    <span class="mybox">&#129718;</span>
    <pinpu-wrapper></pinpu-wrapper>
    <div id="lrc" data-lrc="花潮lrc在线">花潮lrc在线</div>
</div>
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=346591" autoplay loop></audio>

<script>

+function() {
    let pinpuNum = 80, pinpuWidth = 4, pinpuHeight = 200, mKey = 0, mFlag = true, slip = 0.2; let ppwrap = document.querySelector('pinpu-wrapper');
    let lrcAr = [ , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ];
    let mState = () => aud.paused ? (mydiv.style.setProperty('--state','paused'), lrc.style.setProperty('--state','paused')) : (mydiv.style.setProperty('--state','running'), lrc.style.setProperty('--state','running'));
    let showLrc = (time) => {let name = mFlag ? 'cover1' : 'cover2';lrc.innerHTML = lrc.dataset.lrc = lrcAr;lrc.style.setProperty('--motion', name);lrc.style.setProperty('--tt', time + 's');lrc.style.setProperty('--state', 'running');mKey += 1;mFlag = !mFlag;};
    let calcKey = () => {for(j = 0; j < lrcAr.length; j ++) {if(aud.currentTime <= lrcAr) {mKey = j - 1;break;}}if(mKey <0) mKey = 0;if(mKey > lrcAr.length - 1) mKey = lrcAr.length - 1;let time = lrcAr - (aud.currentTime - lrcAr);showLrc(time);};
    let msort = (ar) => {let newAr = [];ar.forEach((v,k) => k % 2 === 0 ? newAr.unshift(v) : newAr.push(v));return newAr;}
    +function() {let ar = Array.from(Array(pinpuNum), (v,k) => pinpuNum - k -1);Array.from({length: pinpuNum}).forEach((item,key) => {item = document.createElement('pin-pu');item.style.cssText += `width: ${pinpuWidth}px;left: ${(pinpuWidth + 2) * key}px;background: #${Math.random().toString(16).substr(-6)};--height: ${15 + (pinpuHeight - 15) / pinpuNum * msort(ar)}px;--du: ${Math.random() * .3 + .3}s;--delay: -${Math.random()}s;--psw: ${pinpuWidth + 2}px`;ppwrap.appendChild(item);});ppwrap.style.height = `${pinpuHeight}px`;ppwrap.style.width = `${(pinpuWidth + 2) * pinpuNum}px`;}();
    aud.addEventListener('play', mState, false);
    aud.addEventListener('pause', mState, false);
    aud.addEventListener('seeked', calcKey, false);
    aud.addEventListener('timeupdate', () => {
    for (j = 0; j < lrcAr.length; j++) {if (aud.currentTime >= lrcAr + slip) {cKey = j;if (mKey === j) showLrc(lrcAr);else continue;}}});
    ppwrap.onclick = () => aud.paused ? aud.play() : aud.pause();
}();

</script>

马黑黑 发表于 2023-7-18 07:29

代码分享
<style>
#mydiv { margin: -80px 0 0 calc(50% - 681px); width: 1200px; height: 675px; background: #cc8c70 url('https://638183.freep.cn/638183/t23/2/wjkx.jpg') no-repeat center/cover; box-shadow: 0 0 8px 0 #000; opacity: .95; overflow: hidden; z-index: 1; position: relative; --state: paused; }
#mydiv::before, #mydiv::after { position: absolute; content: '\1F982'; font-size: 60px; bottom: 15px; left: 40%; }
#mydiv::after { content: '\1FAB2'; transform: translateY(15px) rotate(-10deg); font-size: 40px; }
#lrc { position: absolute; top: 10px; left: 50%; transform: translate(-50%); font: bold 2.4em sans-serif; color: rgb(240,240,240); -webkit-background-clip: text; filter: drop-shadow(1px 1px 2px rgba(0,0,0,.95)); --motion: cover2; --tt: 5s; }
#lrc::before { position: absolute; content: attr(data-lrc); width: 20%; height: 100%; color: transparent; overflow: hidden; white-space: nowrap; background: linear-gradient(180deg,rgba(112,145,180,.45),rgba(86,145,250,.75)); filter: inherit; -webkit-background-clip: text; animation: var(--motion) var(--tt) linear forwards var(--state); }
pinpu-wrapper { position: absolute; bottom: 80px; left: 285px; cursor: pointer; }
pin-pu { position: absolute; bottom: 0; animation: pinpuMotion var(--du) var(--delay) infinite alternate linear var(--state); --psw: 6px; }
pin-pu::before { content: ''; position: absolute; left: calc(50% - var(--psw) / 2); width: var(--psw); height: var(--psw); border-radius: 50%; background: snow; }
.mybox { position: absolute; top: -100px; left: 80%; font-size: 50px; animation: down 8s var(--delay) infinite linear var(--state); --delay: 0s; --deg: 5deg; }
.mybox:nth-of-type(2) { --delay: -2s; --deg: -5deg; }
.mybox:nth-of-type(3) { --delay: -4s; --deg: -15deg; }
.mybox:nth-of-type(4) { --delay: -6s; --deg: -15deg; }
@keyframes pinpuMotion { from { height: 0px; } to { height: var(--height); } }
@keyframes down { to { transform: rotate(var(--deg)) translateY(800px) rotate(360deg); } }
@keyframes cover1 { from { width: 0; } to { width: 100%; } }
@keyframes cover2 { from { width: 0; } to { width: 100%; } }
</style>

<div id="mydiv">
    <span class="mybox">&#129718;</span>
    <span class="mybox">&#129718;</span>
    <span class="mybox">&#129718;</span>
    <span class="mybox">&#129718;</span>
    <pinpu-wrapper></pinpu-wrapper>
    <div id="lrc" data-lrc="花潮lrc在线">花潮lrc在线</div>
</div>
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=346591" autoplay loop></audio>

<script>

+function() {
    let pinpuNum = 80, pinpuWidth = 4, pinpuHeight = 200, mKey = 0, mFlag = true, slip = 0.2; let ppwrap = document.querySelector('pinpu-wrapper');
    let lrcAr = [ , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ];
    let mState = () => aud.paused ? (mydiv.style.setProperty('--state','paused'), lrc.style.setProperty('--state','paused')) : (mydiv.style.setProperty('--state','running'), lrc.style.setProperty('--state','running'));
    let showLrc = (time) => {let name = mFlag ? 'cover1' : 'cover2';lrc.innerHTML = lrc.dataset.lrc = lrcAr;lrc.style.setProperty('--motion', name);lrc.style.setProperty('--tt', time + 's');lrc.style.setProperty('--state', 'running');mKey += 1;mFlag = !mFlag;};
    let calcKey = () => {for(j = 0; j < lrcAr.length; j ++) {if(aud.currentTime <= lrcAr) {mKey = j - 1;break;}}if(mKey <0) mKey = 0;if(mKey > lrcAr.length - 1) mKey = lrcAr.length - 1;let time = lrcAr - (aud.currentTime - lrcAr);showLrc(time);};
    let msort = (ar) => {let newAr = [];ar.forEach((v,k) => k % 2 === 0 ? newAr.unshift(v) : newAr.push(v));return newAr;}
    +function() {let ar = Array.from(Array(pinpuNum), (v,k) => pinpuNum - k -1);Array.from({length: pinpuNum}).forEach((item,key) => {item = document.createElement('pin-pu');item.style.cssText += `width: ${pinpuWidth}px;left: ${(pinpuWidth + 2) * key}px;background: #${Math.random().toString(16).substr(-6)};--height: ${15 + (pinpuHeight - 15) / pinpuNum * msort(ar)}px;--du: ${Math.random() * .3 + .3}s;--delay: -${Math.random()}s;--psw: ${pinpuWidth + 2}px`;ppwrap.appendChild(item);});ppwrap.style.height = `${pinpuHeight}px`;ppwrap.style.width = `${(pinpuWidth + 2) * pinpuNum}px`;}();
    aud.addEventListener('play', mState, false);
    aud.addEventListener('pause', mState, false);
    aud.addEventListener('seeked', calcKey, false);
    aud.addEventListener('timeupdate', () => {
    for (j = 0; j < lrcAr.length; j++) {if (aud.currentTime >= lrcAr + slip) {cKey = j;if (mKey === j) showLrc(lrcAr);else continue;}}});
    ppwrap.onclick = () => aud.paused ? aud.play() : aud.pause();
}();

</script>

花飞飞 发表于 2023-7-18 08:39

新频谱2.0上线,加了个圆点点,更活泼更好看。。。{:4_199:}

红影 发表于 2023-7-18 09:13

给频谱戴个小圆帽,这个漂亮{:4_199:}

红影 发表于 2023-7-18 09:38

这个频谱的位置特别好,正好分布在宫门旁{:4_173:}

醉美水芙蓉 发表于 2023-7-18 12:05

马黑黑 发表于 2023-7-18 12:15

醉美水芙蓉 发表于 2023-7-18 12:05
有了帽子更漂亮了!

{:4_190:}

马黑黑 发表于 2023-7-18 12:16

红影 发表于 2023-7-18 09:13
给频谱戴个小圆帽,这个漂亮

伪元素频谱帽

马黑黑 发表于 2023-7-18 12:16

红影 发表于 2023-7-18 09:38
这个频谱的位置特别好,正好分布在宫门旁

像素尺量一量

马黑黑 发表于 2023-7-18 12:16

花飞飞 发表于 2023-7-18 08:39
新频谱2.0上线,加了个圆点点,更活泼更好看。。。

还行

花飞飞 发表于 2023-7-18 12:18

马黑黑 发表于 2023-7-18 12:16
还行

我跟了一贴,效果加上了之前那个八爪鱼,只是不确定论坛发有没有问题{:4_173:}可有空瞧瞧?

马黑黑 发表于 2023-7-18 12:19

花飞飞 发表于 2023-7-18 12:18
我跟了一贴,效果加上了之前那个八爪鱼,只是不确定论坛发有没有问题可有空瞧瞧?

一般没啥问题

花飞飞 发表于 2023-7-18 12:20

马黑黑 发表于 2023-7-18 12:19
一般没啥问题

心虚虚。。。我得找个地儿试一下。。

马黑黑 发表于 2023-7-18 12:21

花飞飞 发表于 2023-7-18 12:20
心虚虚。。。我得找个地儿试一下。。

{:4_196:}

红影 发表于 2023-7-18 16:13

马黑黑 发表于 2023-7-18 12:16
伪元素频谱帽

看出来了{:4_173:}

红影 发表于 2023-7-18 16:14

马黑黑 发表于 2023-7-18 12:16
像素尺量一量

我一般都懒得量,都是多调几次调到位{:4_173:}

花飞飞 发表于 2023-7-18 16:58

马黑黑 发表于 2023-7-18 12:21


{:4_198:}

马黑黑 发表于 2023-7-18 17:13

花飞飞 发表于 2023-7-18 16:58


把中括号内的变量 i 写成 [ i ] 就没事了。i 两边没有空格的话,论坛的 ubb 代码机制会捕捉到,然后把它变成 i

花飞飞 发表于 2023-7-18 17:22

马黑黑 发表于 2023-7-18 17:13
把中括号内的变量 i 写成 [ i ] 就没事了。i 两边没有空格的话,论坛的 ubb 代码机制会捕捉到,然后把它 ...
啊啊啊,论坛太自动化了。。。

马黑黑 发表于 2023-7-18 17:24

花飞飞 发表于 2023-7-18 17:22
啊啊啊,论坛太自动化了。。。
我第一次碰到时也是懵逼,后来查看被它修改过的代码才知道是怎么回事。所以,步进变量我极少用 i ,因为需要读取数组元素内容是,离不开 [ i ],一不小心就忘了空格,就出错了。
页: [1] 2 3 4 5 6 7
查看完整版本: Beyond - 无尽空虚