绿 色(马黑黑原创)
本帖最后由 朵拉 于 2022-10-22 22:29 编辑 <br /><br /><style>#papa { left: -214px; width: 1024px; height: 640px; background: url('https://pic1.imgdb.cn/item/6353e50e16f2c2beb1eb897e.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;}
#mplayer { position: absolute; bottom: 20px; display: grid; grid-template-columns: auto auto auto; place-items: center; gap: 6px; user-select: none; }
#btnplay { width: 40px; height: 40px; text-align: center; font: normal 40px/40px sans-serif; color: snow; cursor: pointer; animation: rot linear 4s 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, green); opacity: .75; }
#audtime { font: normal 14px sans-serif; color: snow; }
#lrc { --motion: cover1; --tt: 5s; --state: paused; position: absolute; top: 30px; 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(0,50%,20%,.45),hsla(140,100%,50%,.75)); filter: inherit; -webkit-background-clip: text; animation: var(--motion) var(--tt) linear forwards; animation-play-state: var(--state); }
#fish { offset-path: path('M310 195a93.5 62 0 1 0 187 0a93.5 62 0 1 0 -187 0z'); offset-distance: 100%; animation: swim 50s infinite; }
@keyframes cover1 { from { width: 0; } to { width: 100%; } }
@keyframes cover2 { from { width: 0; } to { width: 100%; } }
@keyframes rot { to { transform: rotate(1turn); } }
@keyframes swim { to { offset-distance: 0%; } }
</style>
<div id="papa">
<img id="fish" src="https://wj1.zp68.com:812/lxx/yunhua/2022/10/02/gnyu.jpg" alt="" />
<div id="lrc" data-lrc="花潮lrc在线">花潮lrc在线</div>
<div id="mplayer">
<span id="btnplay">❁</span>
<span id="prog"></span>
<span id="audtime">00:00 | 00:00</span>
</div>
</div>
<script>
(function() {
let aud = new Audio(), mKey = 0, mFlag = true;
let lrcAr = [,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
];
aud.src = 'https://music.163.com/song/media/outer/url?id=1345848098.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> 朵拉套用成功{:4_178:} 小鱼儿要移动一下位置哦 小辣椒 发表于 2022-10-22 20:52
小鱼儿要移动一下位置哦
小辣椒 晚上好,我还编辑中~~{:4_173:} 朵拉 发表于 2022-10-22 20:54
小辣椒 晚上好,我还编辑中~~
哈哈~~~你编辑我等一下再来欣赏 @马黑黑{:4_190:}
马师好,学生遇到两大问题:
1,同步歌词怎么没有覆盖
2,小鱼儿的位置怎么调整
朵拉 发表于 2022-10-22 21:40
@马黑黑
马师好,学生遇到两大问题:
先说小鱼。你的可视水域,不合适这条鱼游动,建议取消路径:
① CSS 的 #fish 改为:
#fish { position: absolute; left: 55%; top: 82%; transform: rotate(55deg); opacity: .95; }
② CSS 关键帧动画 @keyframes swim { to { offset-distance: 0%; } } 删掉。
再说歌词:你用了升级以前的歌词模式,而这个帖子模板是采用新格式的歌词,我帮你转了一下,用下面这个替换你原来的,但我没有帮你做微调,只是转成新的格式:
let lrcAr = [
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
];
需要微调,可以去我的后院有增强版试试,制作、转换歌词也可以用它,它的歌词兼容以前的模板。
马黑黑 发表于 2022-10-22 22:02
先说小鱼。你的可视水域,不合适这条鱼游动,建议取消路径:
① CSS 的 #fish 改为:
收到,谢谢马师{:4_190:} 朵拉 发表于 2022-10-22 22:30
收到,谢谢马师
小鱼还没有调整? 马黑黑 发表于 2022-10-22 22:32
小鱼还没有调整?
感觉不影响美观,不动了哈{:4_173:} 朵拉 发表于 2022-10-22 22:42
感觉不影响美观,不动了哈
也成,不过还不如弄只小蝴蝶{:4_173:} 以后做或转换歌词,用这个:
https://www.huachaowang.com/forum.php?mod=viewthread&tid=63319 马黑黑 发表于 2022-10-22 22:45
以后做或转换歌词,用这个:
https://www.huachaowang.com/forum.php?mod=viewthread&tid=63319
收到,谢谢马师{:4_190:} 朵拉 发表于 2022-10-22 22:54
收到,谢谢马师
{:5_108:} 这个真漂亮,朵宝真棒{:4_187:}
页:
[1]