醉美水芙蓉 发表于 前天 21:28

静悟音画《祖国一片新面貌》

<style>
      #papa { margin: 30px 0 30px calc(50% - 681px); width: 1200px; height: 760px; background: url('https://pic1.imgdb.cn/item/67afeaced0e0a243d4ff7adc.png') no-repeat center/cover; box-shadow: 3px 3px 8px black; display: grid; place-items: center; position: relative; border-radius:32px; }
      #stage { position: absolute; width: 460px; height: 600px; font-size: 0; 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: 10px;; width: 50px; height: 50px; color:Orange; display: grid; place-items: center; cursor: pointer; }
      #btnplay::before { position: absolute; content: ''; width: 100%; height: 100%; border: 2px dashed cyan; 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://pic1.imgdb.cn/item/67afeb26d0e0a243d4ff7ae4.jpg" />
                <img alt="" src="https://pic1.imgdb.cn/item/67afeb58d0e0a243d4ff7ae7.jpg" />
                <img alt="" src="https://pic1.imgdb.cn/item/67afeb7fd0e0a243d4ff7aeb.jpg" />
                <img alt="" src="https://pic1.imgdb.cn/item/67afeb7fd0e0a243d4ff7aeb.jpg" />
                <img alt="" src="https://pic1.imgdb.cn/item/67afebccd0e0a243d4ff7aef.jpg" />
                <img alt="" src="https://pic1.imgdb.cn/item/67afec48d0e0a243d4ff7af4.jpg" />
      </div>
      <div id="btnplay">1</div>
      <audio id="aud" src="https://music.163.com/song/media/outer/url?id=5273953.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 * 460, 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>

klxf 发表于 前天 22:48

谢谢醉美管理员精彩分享:)

醉美水芙蓉 发表于 昨天 06:10

klxf 发表于 2025-2-20 22:48
谢谢醉美管理员精彩分享

谢谢友友支持!
页: [1]
查看完整版本: 静悟音画《祖国一片新面貌》