相信自己配得上所有的美好(学习黑黑方块龙效果)
<style>#papa {
margin: 120px 0 0 calc(50% - 681px);
width: 1200px;
height: 614px;
background: gray url('https://pic.imgdb.cn/item/6373503316f2c2beb14509b5.jpg') no-repeat
center/cover;
display: grid;
place-items: center;
box-shadow: 3px 3px 20px #000;
user-select: none;
position: relative;
z-index: 1;
}
#mplayer {
position: absolute;
top: 140px;
grid-template-columns: auto auto auto;
gap: 6px;
display: grid;
place-items: center;
}
#btnplay {
margin-right: -4px;
width: 30px;
height: 30px;
color: red;
font: bold 30px/30px serif;
text-align: center;
cursor: pointer;
animation: rot 4s infinite linear;
animation-play-state: var(--state);
--state: paused;
}
#tmsg {
font: normal 16px sans-serif;
color: red;
}
#prog {
width: 200px;
height: 20px;
cursor: pointer;
}
#lrc {
--state: running;
--motion: cover1;
--tt: 5s;
position: absolute;
top: 40px;
font: bold 2.4em sans-serif;
color: hsl(60, 30%, 70%);
-webkit-background-clip: text;
filter: drop-shadow(1px 1px 2px hsla(30, 10%, 10%, .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);
}
#papa > span {
position: absolute;
left: 580px;
width: 30px;
height: 30px;
border-radius: 8px;
border: 1px solid red;
}
#tupian { position: absolute; left:-100px; top:20px; opacity: 0.90; }
@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">
<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>
<img id="tupian" src="https://pic.imgdb.cn/item/63258ace16f2c2beb10576c0.gif" alt="" />
</div>
<audio id="aud" src="http://www.kumeiwp.com/sub/filestores/2021/11/03/ceca8212007228c921c35bd609d69221.mp3"
loop autoplay></audio>
</div>
<script>
(function() {
(function() {let total = 100, rr = 600;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) translateX(${num}px);`;papa.appendChild(item);});})();
let mKey = 0,
mSeek = false,
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('pause', () => mState());
aud.addEventListener('play', () => mState());
aud.addEventListener('seeked', () => calcKey());
aud.addEventListener('timeupdate', () => {
prog.value = aud.currentTime / aud.duration * 100;
changeBgColor();
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;
};
let changeBgColor = () => {let circles = document.querySelectorAll('.circle');circles.style.background = 'none';lastcircle =Math.round(Math.random() * (circles.length - 1));circles.style.background = '#8B4513';};
})();
</script> 亲爱的好棒,这个变色龙做出来了{:4_199:} 我也是喜欢这条变色龙{:4_170:}
稍等我去发 小辣椒 发表于 2022-11-15 19:49
亲爱的好棒,这个变色龙做出来了
我把这条龙横过来了,我找的图图高度不够,横着放比较好{:4_173:} 小辣椒 发表于 2022-11-15 19:50
我也是喜欢这条变色龙
稍等我去发
我都好长时间没完成作业了,特不好意思{:4_173:} 红影 发表于 2022-11-15 19:59
我把这条龙横过来了,我找的图图高度不够,横着放比较好
是的,你这样挺好,按图图尺寸放{:4_199:} 红影 发表于 2022-11-15 20:00
我都好长时间没完成作业了,特不好意思
没事啊,忙工作要紧 小辣椒 发表于 2022-11-15 20:02
是的,你这样挺好,按图图尺寸放
数学公式没理解,反正就跟着混着玩了{:4_173:} 小辣椒 发表于 2022-11-15 20:02
没事啊,忙工作要紧
总算忙得差不多了,谢谢亲爱的牵挂{:4_179:} 红影 发表于 2022-11-15 19:59
我把这条龙横过来了,我找的图图高度不够,横着放比较好
横而不躺平,精妙的设计!赞。 红影 发表于 2022-11-15 20:21
总算忙得差不多了,谢谢亲爱的牵挂
下面是我要忙了 红影 发表于 2022-11-15 20:20
数学公式没理解,反正就跟着混着玩了
哈哈,做出来有改变就是成功 马黑黑 发表于 2022-11-15 20:21
横而不躺平,精妙的设计!赞。
这个白天就开始弄了,白天只能听酷美的歌儿,正好看到这首,觉得还不错,就赶紧做了个{:4_173:} 小辣椒 发表于 2022-11-15 20:23
下面是我要忙了
亲爱的注意身体,你身体不好,别太累{:4_204:} 小辣椒 发表于 2022-11-15 20:25
哈哈,做出来有改变就是成功
都是套用代码,总能弄出来的啊。只是做出来的没亲爱的弄得漂亮{:4_173:} 红影 发表于 2022-11-15 21:06
亲爱的注意身体,你身体不好,别太累
是啊,我后面会有点累,以前休息的太多。。。年底了 红影 发表于 2022-11-15 21:07
都是套用代码,总能弄出来的啊。只是做出来的没亲爱的弄得漂亮
没有啊,你的也是漂亮的 红影 发表于 2022-11-15 21:05
这个白天就开始弄了,白天只能听酷美的歌儿,正好看到这首,觉得还不错,就赶紧做了个
效果出色 好一条变色龙啊!