等你等到我心痛(学习马黑黑scroll版纵向翻页效果)
<style>#papa { margin: 30px 0 30px calc(50% - 601px); width: 1200px; height: 720px; background: url('https://pic.imgdb.cn/item/6523e9d3c458853aef5f19cf.jpg') no-repeat center/cover; box-shadow: 3px 3px 8px black; display: grid; place-items: center; position: relative; }
#stage { position: absolute; width: 460px; height: 600px; overflow: hidden; cursor: pointer; }
#stage img { width: 100%; height: 100%; float: left; mask: radial-gradient(closest-side, red, red, transparent); }
#stage img:hover { mask: unset; }
#btnplay { --state: running; position: absolute; bottom: 10px;; width: 30px; height: 30px; color: white; 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/67b053e1d0e0a243d4ff9922.jpg" />
<img alt="" src="https://pic1.imgdb.cn/item/67b053f2d0e0a243d4ff9925.jpg" />
<img alt="" src="https://pic1.imgdb.cn/item/67b053ecd0e0a243d4ff9924.jpg" />
<img alt="" src="https://pic1.imgdb.cn/item/67b053f8d0e0a243d4ff9926.jpg" />
<img alt="" src="https://pic1.imgdb.cn/item/67b053ffd0e0a243d4ff9928.jpg" />
<img alt="" src="https://pic1.imgdb.cn/item/67b053e7d0e0a243d4ff9923.jpg" />
</div>
<div id="btnplay">1</div>
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=2669253004" 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({top: idx * stage.clientHeight, 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();
papa.scrollIntoView(true);
</script> @马黑黑
老师好,学生交作业,请指正{:4_190:} 欣赏点赞!好快乐的速度。{:4_199:} 不错 欣赏朵拉美帖,速度杠杠的{:4_199:} 漂亮。欣赏朵宝好帖{:4_187:}
页:
[1]