|
|

楼主 |
发表于 2023-4-11 13:40
|
显示全部楼层
<style>
#papa { left: -252px;top:120px; width: 1100px; height: 618px; background: gray url('https://pic.imgdb.cn/item/643498690d2dde5777c00978.jpg')
no-repeat center/cover; box-shadow: 4px 4px 24px #000; position: relative; }
#mama { position: absolute; left: 100px; top: calc(50% - 140px); display: grid; place-items: center; width: 360px; height: 360px; cursor: pointer; }
#tit { position: absolute; left: 26px; top: 46px; font: bold 26px / 26px sans-serif; color: #4D0CAF; text-shadow: 1px 1px 2px rgba(0,0,0,.8); }
.txt { position: absolute; width: 60px; height: 60px; font: bold 40px / 60px sans-serif; text-align: center; text-shadow: 2px 2px 4px rgba(0,0,0,.4); border-radius: 50%; color: snow; }
</style>
<div id="papa">
<span id="tit">给朝云暮雨转个轱辘</span>
<div id="mama"><span id="sMsg" class="txt">1</span></div>
<div style="position: absolute; left:560px; top: 250px; width:451px;">
<img alt="" src="https://pic.imgdb.cn/item/62479cbe27f86abb2adbb9bd.gif"/></div>
</div><br><br><br><br><br><br>
<script>
let idx = 0, step = 0;
let strAr = '卧女神游旦暮楚山新雨洗朝云'.split(''), spans = [],
sentences = [
[7,8,9,9],
[10,11,12,12],
[0,1,2,2],
[3,4,5,5],
[6,7,8,9,9],
[9,10,11,12,12],
[12,0,1,2,2],
[2,3,4,5,5],
[5,6,7,8,9,9],
[8,9,10,11,12,12],
[11,12,0,1,2,2],
[1,2,3,4,5,5],
[3,4,5,6,7,8,9,9],
[6,7,8,9,10,11,12,12],
[9,10,11,12,0,1,2,2],
[12,0,1,2,3,4,5,5],
];
let aud = new Audio();
aud.src = 'https://music.163.com/song/media/outer/url?id=161114.mp3';
aud.loop = true;
aud.autoplay = true;
let num = (min, max) => Math.floor(Math.random() * (max-min+1)) + min;
for(let x in strAr) {
let ele = document.createElement('span');
ele.className = 'txt';
ele.innerText = strAr[x];
ele.style.transform = `rotate(${x*27.6}deg) translateY(180px) rotate(${-x*27.6}deg)`;
mama.appendChild(ele);
spans.push(ele);
}
txtColor()
txtCircle();
mama.onclick = () => aud.paused ? aud.play() : aud.pause();
function txtColor() {
for(let y of spans) {
y.style.color = 'snow';
y.style.border = 'none';
}
for(let x of sentences[idx]) spans[x].style.color = `rgb(${num(0,255)},${num(0,255)},${num(0,255)})`;
sMsg.innerText = idx + 1;
}
function txtCircle() {
let x = sentences[idx][step];
spans[x].style.border = '1px solid purple';
step ++;
if(step > sentences[idx].length - 1) {
step = 0;
idx ++;
if(idx > sentences.length - 1) idx = 0;
txtColor();
}
setTimeout(txtCircle, 1500);
}
</script>
|
|