小小的太阳 TO:马黑黑
本帖最后由 朵拉 于 2023-12-10 23:00 编辑 <br /><br /><style>#papa { margin: 0 0 0 calc(50% - 593px); width: 1024px; height: 640px; background: #666 url('https://pic.imgdb.cn/item/6575d214c458853aef65a461.jpg') no-repeat center/cover; overflow: hidden; display: grid; place-items: center; box-shadow: 3px 6px 12px gray; position: relative; --state: paused; }
#player { width: 300px; cursor: pointer; animation: rotating 18s linear infinite var(--state); }
mov-ball { position: absolute; width: 20px; height: 20px; border-radius: 50%; background: tan; animation: imov 6s infinite; }
@keyframes moving {
from { opacity: 0; transform: translate(0,0); }
to { opacity: 1; transform: translate(var(--x0),var(--y0)); }
}
@keyframes rotating { to { transform: rotate(360deg); } }
</style>
<div id="papa">
<img id="player" src="https://638183.freep.cn/638183/web/svg/sunfl-1.svg" alt="" title="" />
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=1364418240" autoplay loop></audio>
</div>
<script>
(function() {
let all = 100;
for(let i = 0; i < all; i++) {
let movBall = document.createElement('mov-ball');
let hudu = Math.PI / 180 * 360 / all * i;
let xx = 600 * Math.cos(hudu), yy = 600 * Math.sin(hudu);
movBall.style.cssText += `
--x0: ${xx}px;
--y0: ${yy}px;
background: #${Math.random().toString(16).substr(-6)};
animation: moving ${Math.random() * 20 + 20}s -${Math.random() * 20}s infinite var(--state);
`;
papa.prepend(movBall);
}
let playMusic = () => aud.paused ? (aud.play(), player.title='暂停') : (aud.pause(), player.title='播放');
let mState = () => papa.style.setProperty('--state', aud.paused ? 'paused' : 'running');
aud.addEventListener('playing',mState,false);
aud.addEventListener('pause',mState,false);
player.addEventListener('click',playMusic,false);
})();
</script> @马黑黑
马师 晚上好,学生交作业,望喜欢哈~~{:4_190:} 朵拉 发表于 2023-12-10 23:01
@马黑黑
马师 晚上好,学生交作业,望喜欢哈~~
速度很快,也做的相当不错 朵宝的套用也很漂亮。欣赏朵宝好帖{:4_187:} 欣赏佳作,感谢分享 送礼收礼的统统开心 世外桃源 发表于 2023-12-11 15:11
送礼收礼的统统开心
感谢老师的临帖,祝您新周愉快{:4_190:}
页:
[1]