本帖最后由 花简静 于 2024-8-18 15:29 编辑
<style>
#papa { margin: 130px 0 20px calc(50% - 931px); width: 1700px; height: 900px; background: url('https://642303.freep.cn/642303/tu/qishansz06.webp') no-repeat center/cover; box-shadow: 3px 3px 6px rgba(0, 0, 0, .5); position: relative; }
#mama { position: absolute; width: 100%; height: 100%;mix-blend-mode: screen;opacity: .58; }
#background { display: none; }
#player { position: absolute; left: 490px; bottom: 280px; cursor: pointer; z-index: 100; opacity: .65; animation: rot 10s linear infinite var(--state); }
@keyframes rot { to { transform: rotate(1turn); } }
</style>
<div id="papa">
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=410161058" autoplay loop></audio>
<!-- mama是约束水珠的载体,它需要通过CSS设置为绝对定位 -->
<div id="mama"></div>
<img id="player" src="https://642303.freep.cn/642303/za/4yc0.png" width="120" height="120" alt="" />
</div>
<script>
var engine;
var sF = document.createElement('script');
sF.src = 'https://638183.freep.cn/638183/web/js/rainyday.js';
document.body.appendChild(sF);
sF.onload = function() {
var image = new Image();
image.crossOrigin = 'anonymous';
image.onload = function() {
engine = new RainyDay({
image: this,
parentElement: mama,
});
var canv = document.querySelector('#papa canvas');
canv.style.cssText += 'left: 0; top: 0';
mState();
};
//图片地址(需支持跨域)
image.src = 'https://642303.freep.cn/642303/tu/0513di.webp';
var mState = () => {
papa.style.setProperty('--state', aud.paused ? 'paused' : 'running');
aud.paused ? engine.pause() : engine.resume();
};
aud.onplaying = aud.onpause = () => mState();
player.onclick = () => aud.paused ? aud.play() : aud.pause();
};
</script>
<br><br><br><br><br><br>
|