朵拉 发表于 2022-11-20 21:01

Disco

本帖最后由 朵拉 于 2023-5-25 21:27 编辑 <br /><br /><style>
#papa {
      margin: 100px 0 0 calc(50% - 621px);
      width: 1080px;
      height: 721px;
      background: gray url('https://pic.imgdb.cn/item/637a244216f2c2beb1a42d84.png') no-repeat center/cover;
      display: grid;
      place-items: center;
      box-shadow: 3px 3px 20px #000;
      user-select: none;
      overflow: hidden;
      perspective: 1000px;
      position: relative;
      z-index: 1;
}

#mplayer {
      position: absolute;
      bottom: 20px;
      grid-template-columns: auto auto auto;
      gap: 6px;
      display: grid;
      place-items: center;
      font: normal 16px sans-serif;
      color:blue;
      z-index: 999;
}

#btnplay {
      margin-right: -4px;
      width: 30px;
      height: 30px;
      font: bold 30px/30px serif;
      text-align: center;
      cursor: pointer;
      animation: rot 4s infinite linear;
      animation-play-state: var(--state);
      --state: paused;
}

#prog {
      width: 200px;
      height: 20px;
      cursor: pointer;
}

#lrc {
      --state: running;
      --motion: cover2;
      --tt: 1s;
      position: absolute;
      top: 20px;
      font: bold 2.4em sans-serif;
      color: hsl(240, 50%, 90%);
      -webkit-background-clip: text;
      filter: drop-shadow(1px 1px 2px hsla(30, 10%, 10%, .95));
      z-index: 1000;
}

#lrc::before {
      position: absolute;
      content: attr(data-lrc);
      width: 20%;
      height: 100%;
      color: orange;
      overflow: hidden;
      white-space: nowrap;
      background: linear-gradient(180deg, hsla(240, 60%, 50%, .45), hsla(240, 100%, 60%, .75));
      filter: inherit;
      -webkit-background-clip: text;
      animation: var(--motion) var(--tt) linear forwards;
      animation-play-state: var(--state);
}
.star {
      --rr: 300px;
      position: absolute;
      width: 4px;
      height: 4px;
      border-radius: 50% 50% 25% 50%;
      transform-origin: 50% 50%;
      transform-style: preserve-3d;
}
@keyframes cover1 { from { width: 0; } to { width: 100%; } }
@keyframes cover2 { from { width: 0; } to { width: 100%; } }
@keyframes rot { to { transform: rotate(1turn); } }
@keyframes fly { to { transform: rotate(0) translate(0); } }
</style>

<div id="papa">
      <div id="lrc" data-lrc="花潮论坛lrc在线">花潮论坛lrc在线</div>
      <div id="mplayer">
                <span id="btnplay">◑</span>
                <meter id="prog" low="30" high="90" max="100" optimum="100" value="1"></meter>
                <span id="tmsg">00:00 | 00:00</span>
      </div>
</div>
<audio id="aud" src="http://www.kumeiwp.com/sub/filestores/2022/03/14/0cb35b3ea0bc4a285f35ebc1077eb49c.mp3" loop autoplay></audio>

<script>
(function() {
      let mKey = 0, mSeek = false, mFlag = true;
      let lrcAr = [,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,];
      (function() {
                Array.from({length: 100}).forEach((item,key) => {
                        item = document.createElement('span');
                        item.className = 'star';
                        let ww = Math.ceil(Math.random() * 20) | 10;
                        item.style.cssText += `
                              width: ${ww}px;
                              height: ${ww}px;
                              left: ${Math.random()*200 + 500}px;
                              top: ${Math.random()*100 + 240}px;
                              background: hsla(${360*Math.random()},100%,50%,.75);
                              transform: rotate(${Math.random() * 720}deg) translate3d(${Math.random() * 500}px,${Math.random() * 300}px,${Math.random() * 1000}px);
                              animation: fly 80s infinite ${-10 - Math.random() * 20}s linear;
                        `;
                        papa.appendChild(item);
                });
      })();
      btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
      prog.onclick = (e) => aud.currentTime = aud.duration * e.offsetX / prog.offsetWidth;
      aud.addEventListener('pause', () => mState());
      aud.addEventListener('play', () => mState());
      aud.addEventListener('seeked', () => calcKey());
      aud.addEventListener('timeupdate', () => {
                prog.value = aud.currentTime / aud.duration * 100;
                tmsg.innerText = `${toMin(aud.currentTime)} | ${toMin(aud.duration)}`;
                for (j = 0; j < lrcAr.length; j++) {
                        if (aud.currentTime >= lrcAr) {
                              if (mKey === j) showLrc(lrcAr);
                              else continue;
                        }
                }
      });
      let mState = () => aud.paused ? (btnplay.style.setProperty('--state', 'paused'), lrc.style.setProperty('--state', 'paused')) : (btnplay.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 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;};
})();
</script>

红影 发表于 2022-11-20 21:06

气球满天飞,这个真漂亮。标题的ASD是什么意思啊,看昨天那个帖子也是先用的这个标题后来改的{:4_173:}

朵拉 发表于 2022-11-20 21:09

红影 发表于 2022-11-20 21:06
气球满天飞,这个真漂亮。标题的ASD是什么意思啊,看昨天那个帖子也是先用的这个标题后来改的

影宝神速,我正在关门制作中,稍等哈{:4_204:}

红影 发表于 2022-11-20 21:21

朵拉 发表于 2022-11-20 21:09
影宝神速,我正在关门制作中,稍等哈

原来是这样,是我擅闯了{:4_173:}

朵拉 发表于 2022-11-20 21:30

@马黑黑
马师看过来,请教 歌词颜色是哪一句哈{:4_190:}

亦是金 发表于 2022-11-20 22:12

本帖最后由 亦是金 于 2022-11-20 22:15 编辑

歌词颜色应该是在这里!颜色可以用#fce235......等替换

马黑黑 发表于 2022-11-20 22:19

朵拉 发表于 2022-11-20 21:30
@马黑黑
马师看过来,请教 歌词颜色是哪一句哈

#lrc

#lrc::before

朵拉 发表于 2022-11-20 22:35

亦是金 发表于 2022-11-20 22:12
歌词颜色应该是在这里!颜色可以用#fce235......等替换

谢谢亦是金朋友{:4_190:}

朵拉 发表于 2022-11-20 22:38

马黑黑 发表于 2022-11-20 22:19
#lrc

#lrc::before

马师 我微调了一下颜色,请指正{:4_190:}

马黑黑 发表于 2022-11-21 07:09

朵拉 发表于 2022-11-20 22:38
马师 我微调了一下颜色,请指正

这样更漂亮了。颜色的调法,除了用单一颜色表示,还可以用线性渐变

冬天的雨 发表于 2022-11-26 18:39

欣赏朵拉的漂亮制作{:4_187:}
页: [1]
查看完整版本: Disco