朵拉 发表于 2022-10-29 17:47

Upupu(马黑黑原创)

本帖最后由 朵拉 于 2022-10-29 18:09 编辑 <br /><br /><style>
#papa {left: -214px; width: 1024px; height: 640px; background: url('https://pic1.imgdb.cn/item/635cf60716f2c2beb1fdf187.jpg') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; display: grid; place-items: center; user-select: none; z-index: 1; --opt: .25; }
#papa::before { position: absolute;left: 700px; top: 400px;content: url('https://638183.freep.cn/638183/t22/gif/girl.gif'); width: 160px; height: 60px; mix-blend-mode: multiply; }
#mplayer { position: absolute; bottom: 10px; display: grid; grid-template-columns: auto auto auto; place-items: center; gap: 6px; user-select: none; }
#btnplay {border-radius: 50%; width: 50px; height: 50px; cursor: pointer; animation: rot linear 3s infinite; }
#prog { --ww: 0px; width: 300px; height: 12px; border: 1px solid green; border-radius: 6px; background: snow; opacity: .65; position: relative; }
#prog::before { position: absolute; content: ''; width: var(--ww); height: 12px; border-radius: 6px; background: snow linear-gradient(90deg, orange, red); opacity: .65; }
#audtime { font: normal 14px sans-serif; color: hsl(0,80%,50%); }
#lrc { --motion: cover1; --tt: 5s; --state: paused; position: absolute; bottom: 60px; font: bold 2.4em sans-serif; color: hsl(0,10%,90%); -webkit-background-clip: text; filter: drop-shadow(1px 1px 2px hsla(0,0%,0%,.95)); }
#lrc::before { position: absolute; content: attr(data-lrc); width: 20%; height: 100%; color: transparent; overflow: hidden; white-space: nowrap; background: linear-gradient(180deg,hsla(60,50%,50%,.45),hsla(0,100%,50%,.75)); filter: inherit; -webkit-background-clip: text; animation: var(--motion) var(--tt) linear forwards; animation-play-state: var(--state); }
@keyframes cover1 { from { width: 0; } to { width: 100%; } }
@keyframes cover2 { from { width: 0; } to { width: 100%; } }
@keyframes rot { to { transform: rotate(1turn); } }
</style>

<div id="papa">
      <div id="lrc" data-lrc="花潮lrc在线">花潮lrc在线</div>
      <div id="mplayer">
                <img id="btnplay" src="https://638183.freep.cn/638183/t22/btn/g1.png" alt="" />
                <span id="prog"></span>
                <span id="audtime">00:00 | 00:00</span>
      </div>
</div>

<script>
(function() {
      let aud = new Audio(), mKey = 0, mFlag = true, down = true;
      let lrcAr = [,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ];
      aud.src = 'https://music.163.com/song/media/outer/url?id=1922374770.mp3';
      aud.loop = true;
      aud.autoplay = true;
      if(aud.paused) btnplay.style.animationPlayState = 'paused';
      btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
      prog.onclick = (e) => aud.currentTime = aud.duration * e.offsetX / prog.offsetWidth;
      aud.addEventListener('seeked', () => calcKey());
      aud.addEventListener('pause', () =>mState());
      aud.addEventListener('play', () =>mState());
      aud.addEventListener('timeupdate', () => {let prg = aud.currentTime * prog.offsetWidth / aud.duration < 6 ? 6 : aud.currentTime * prog.offsetWidth / aud.duration;prog.style.setProperty('--ww', prg + 'px');audtime.innerText = toMin(aud.currentTime) + ' | ' + toMin(aud.duration);for(j=0; j<lrcAr.length; j++) {if(aud.currentTime >= lrcAr) {cKey = j;if(mKey === j) showLrc(lrcAr);else continue;}}});
      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 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 mState = () => aud.paused ? (btnplay.style.animationPlayState='paused',lrc.style.setProperty('--state', 'paused'),papa.style.setProperty('--opt','0')) : (btnplay.style.animationPlayState='running', lrc.style.setProperty('--state', 'running'),papa.style.setProperty('--opt','.25'));
      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-10-29 17:59

@马黑黑
马师好 看过来,这个小女孩怎么调整位置{:4_190:}

马黑黑 发表于 2022-10-29 18:03

朵拉 发表于 2022-10-29 17:59
@马黑黑
马师好 看过来,这个小女孩怎么调整位置

小姑凉是用伪元素放置的,在CSS里,这句:

#papa::before { position: absolute; content: url('https://638183.freep.cn/638183/t22/gif/girl.gif'); width: 160px; height: 60px; mix-blend-mode: multiply; }


上面这句,默认绝对居中。调整位置的话,需要加入 left 和 top 值(具体的值自己调整):


#papa::before { position: absolute; left: 500px; top: 50px; content: url('https://638183.freep.cn/638183/t22/gif/girl.gif'); width: 160px; height: 60px; mix-blend-mode: multiply; }

朵拉 发表于 2022-10-29 18:14

马黑黑 发表于 2022-10-29 18:03
小姑凉是用伪元素放置的,在CSS里,这句:

#papa::before { position: absolute; content: url('https ...

马师在线呢,我大概调整了一下下,您瞧瞧看{:4_190:}

红影 发表于 2022-10-29 19:12

漂亮,恭喜朵宝做成功了{:4_187:}

起个网名好难 发表于 2022-10-29 19:15

本帖最后由 起个网名好难 于 2022-10-29 19:16 编辑



把 &#160;换成 \u00A0 试试



马黑黑 发表于 2022-10-29 19:15

朵拉 发表于 2022-10-29 18:14
马师在线呢,我大概调整了一下下,您瞧瞧看

你呼叫俺得上来的{:4_170:}

现在效果不错呢

马黑黑 发表于 2022-10-29 19:18

本帖最后由 马黑黑 于 2022-10-29 19:20 编辑

歌词中,

Up Up A Up Up DaDaDa",6.8],

英文部分出现转义符 “& # 160; ”,如没必要,可以删掉

樵歌 发表于 2022-10-29 21:00

简洁明了,越做越好1{:4_204:}
页: [1]
查看完整版本: Upupu(马黑黑原创)