继续学习图片转换效果
<style>
#papa { margin: 130px 0 30px calc(50% - 781px); width: 1400px; height: 710px; background: url('https://xlaj.cn/upfile/2025/02/14/002.jpg') no-repeat center/cover; box-shadow: 3px 3px 8px black; display: grid; place-items: center; position: relative; border-radius:24px;}
#stage { position: absolute; font-size: 0; width: 350px; height: 480px; left: 200px;top:20px;border-radius: 50%; overflow: hidden; white-space: nowrap; cursor: pointer; }
#stage img { width: 100%; height: 100%; mask: radial-gradient(red, transparent); }
#stage img:hover { mask: unset; }
#btnplay { --state: running; position: absolute; bottom: 30%; width: 30px; height: 30px;left: 38%; color: Crimson; display: grid; place-items: center; cursor: pointer; }
#btnplay::before { position: absolute; content: ''; width: 100%; height: 100%; border: 2px dashed Black; border-radius: 50%; animation: rot 8s linear infinite var(--state); }
#btnplay:hover::before { border-style: dotted; }
@keyframes rot { to { transform: rotate(360deg); } }
</style>
<div id="papa">
<div id="stage">
<img alt="" src="https://xlaj.cn/upfile/2025/02/14/01.jpg" />
<img alt="" src="https://xlaj.cn/upfile/2025/02/14/02.jpg" />
<img alt="" src="https://xlaj.cn/upfile/2025/02/14/03.jpg" />
<img alt="" src="https://xlaj.cn/upfile/2025/02/14/04.jpg" />
<img alt="" src="https://xlaj.cn/upfile/2025/02/14/05.jpg" />
<img alt="" src="https://xlaj.cn/upfile/2025/02/14/06.jpg" />
<img alt="" src="https://xlaj.cn/upfile/2025/02/14/07.jpg" />
<img alt="" src="https://xlaj.cn/upfile/2025/02/14/08.jpg" />
</div>
<div id="btnplay">1</div>
<audio id="aud" src="https://wj1.zp68.com:812/lxx/yunhua/20200512/yy/11.mp3" autoplay loop></audio>
</div>
<script>
var lastIdx = 0, pTimer;
var images = stage.querySelectorAll('img');
var mState = () => {
btnplay.style.setProperty('--state', aud.paused ? 'paused' : 'running');
btnplay.title = stage.title = aud.paused ? '点击播放' : '点击暂停';
aud.paused ? clearTimeout(pTimer) : turn2();
};
var turn2 = (idx) => {
idx = Math.floor(Math.random() * images.length);
if(idx === lastIdx) idx = (idx+1) % images.length;
lastIdx = idx;
btnplay.innerText = idx + 1;
stage.scroll({left: idx * 350, top: 0, behavior: 'smooth'});
if(pTimer) clearTimeout(pTimer);
pTimer = setTimeout(turn2, 3000);
};
aud.onpause = aud.onplaying = () => mState();
stage.onclick = btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
</script> 情侣装出场{:5_150:} 这首歌好像小辣椒以前分享过的{:5_128:} 爱情里没有谁对谁错{:5_128:} 好听,感谢分享{:5_124:}
页:
[1]