人生百味用微笑面对
本帖最后由 醉美水芙蓉 于 2022-11-17 21:48 编辑 <br /><br /><style>#papa { margin: 120px 0 0 calc(50% - 681px); width: 1200px; height: 800px; background: #666 url('https://img-baofun.zhhainiao.com/fs/scene/preview_img_raw/23c4898d4d381f275db0235f56eac563_preview_raw.jpg') no-repeat center/cover; box-shadow: 3px 3px 20px #000; display: grid; place-items: center; position: relative; z-index: 1; }#mplayer { position: absolute; display: grid; grid-template-areas: 'cur btnplay dur' 'prog prog prog'; gap: 4px; place-items: end center; font-size: 14px; bottom: 20px;left: 900px;}
#cur { grid-area: cur; color: snow; }
#dur { grid-area: dur; color: snow; }
#btnplay { grid-area: btnplay; display: grid; grid-auto-flow: column; place-items: end center; gap: 4px; height: 60px; cursor: pointer; }
#btnplay > span { background: red; width: 4px; transition: .6s; }
#prog { --ww: 0px; grid-area: prog; width: 260px; height: 12px; border-radius: 6px; background: snow; opacity: .65; cursor: pointer; position: relative; }
#prog::before { position: absolute; content: ''; width: var(--ww); height: 12px; border-radius: 6px; background: snow linear-gradient(90deg, green,red); opacity: .65; }
#lrc { --motion: cover1; --tt: 5s; --state: paused; position: absolute; top: 720px; font: bold 2em sans-serif; color: hsl(60, 30%, 70%); -webkit-background-clip: text; filter: drop-shadow(1px 1px 2px hsla(0, 0%, 0%, .95)); z-index: 999; }
#lrc::before { position: absolute; content: attr(data-lrc); width: 20%; height: 100%; color: transparent; overflow: hidden; white-space: pre; 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); }
#papa > span { position: absolute; left: 300px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid red; }
@keyframes cover1 { from { width: 0; } to { width: 100%; } }
@keyframes cover2 { from { width: 0; } to { width: 100%; } }
</style>
<div id="papa">
<div id="lrc" data-lrc="花潮lrc在线">花潮lrc在线</div>
<div id="mplayer">
<div id="cur">00:00</div>
<div id="btnplay"></div>
<div id="dur">00:00</div>
<div id="prog"></div>
</div>
<audio id="aud" src="https://www.qqmc.com/up/kwlink.php?id=249746546&.mp3" loop autoplay></audio>
</div>
<script>
(function() {
(function() {let total = 100, rr = 700;Array.from({length: total}).forEach((item,key) => {item = document.createElement('span');let num = rr * key / total;if(num > rr / 2) num -= rr;item.className='circle';item.style.cssText += `border-color: #${Math.random().toString(16).substr(-6)};transform: rotate(${(360/total) * key}deg) translateY(${num}px);`;papa.appendChild(item);});})();
(function() {for(j=0; j<20; j++) {let pinpu = document.createElement('span');pinpu.className = 'pinpu';pinpu.style.cssText += `height: ${Math.floor(Math.random()*50) + 10}px; background: #${Math.random().toString(16).substr(-6)};`;btnplay.appendChild(pinpu);}})();
let mKey = 0, mFlag = true, lastcircle = 0;
let lrcAr = [
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
];
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');cur.innerText = toMin(aud.currentTime);dur.innerText = toMin(aud.duration);setPinpu();changeBgColor();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 = lrcAr;lrc.dataset.lrc = lrcAr.replace(/<br>/,'\n'); lrc.style.setProperty('--motion', name);lrc.style.setProperty('--tt', time + 's');lrc.style.setProperty('--state', 'running');mKey += 1;mFlag = !mFlag;};
let mState = () => lrc.style.setProperty('--state', aud.paused ? 'paused' : 'running');
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;};
let setPinpu = ()=> {let eles = document.querySelectorAll('.pinpu');eles.forEach((item) => item.style.height = `${Math.floor(Math.random()*50) + 10}px`);};
let changeBgColor = () => {let circles = document.querySelectorAll('.circle');circles.style.background = 'none';lastcircle = Math.round(Math.random() * (circles.length - 1));circles.style.background = 'red';};
})();
</script> 这个龙也是用的圆圈串起来的,画面真漂亮,歌词同步也好。欣赏水芙蓉好帖{:4_187:} 红影 发表于 2022-11-17 22:01
这个龙也是用的圆圈串起来的,画面真漂亮,歌词同步也好。欣赏水芙蓉好帖
谢谢红影美女光临! {:4_208:} 马黑黑 发表于 2022-11-17 23:28
欢迎黑黑老师光临指导! 醉美水芙蓉 发表于 2022-11-17 22:50
谢谢红影美女光临!
不客气,问好水芙蓉,周末快乐{:4_187:}
页:
[1]