马黑黑 发表于 2022-8-4 13:32

天际

<style>
#papa { left: -214px; width: 1024px; height: 600px; background: #336699 url('https://638183.freep.cn/638183/Pic/81/7036.jpg') no-repeat center/cover; box-shadow: 3px 3px 30px #000; position: relative; overflow: hidden; }
.mpic { position: absolute; width: 124px; height: 221px; right: -124px; bottom: -130px; }
#disc { position: absolute; width: 60px; height: 60px; right: 20px; bottom: 20px; background: conic-gradient(red,orange,yellow,green,teal,blue,purple); border-radius: 50%; mask: radial-gradient(transparent 4px,red 0); -webkit-mask: radial-gradient(transparent 4px,red 0); animation: rot 2s linear infinite; cursor: pointer; z-index: 100; }
@keyframes rot { to { transform: rotate(360deg); } }
@keyframes shot { from {transform: translate(0px, 0px) rotate(-45deg); } to { transform: translate(-1084px, -600px) rotate(-45deg); }}
</style>

<div id="papa"><span id="disc"></span></div>

<script>
let arr = , aud = new Audio();

aud.src = 'https://music.163.com/song/media/outer/url?id=1428166708.mp3';
aud.loop = true;
aud.autoplay = true;

disc.style.animationPlayState = aud.paused ? 'paused' : 'running';

for(x of arr) {
        let ele = document.createElement('img');
        ele.className = 'mpic';
        ele.src = 'https://638183.freep.cn/638183/Pic/81/tj.gif';
        ele.alt = '';
        ele.style.animation = 'shot 4s linear ' + x * .6 + 's infinite';
        papa.appendChild(ele);
}

disc.onclick = () => aud.paused ? aud.play() : aud.pause();
aud.addEventListener('playing',()=> disc.style.animationPlayState = 'running');
aud.addEventListener('pause',()=> disc.style.animationPlayState = 'paused');

</script>

马黑黑 发表于 2022-8-4 13:36

代码分享:
<style>
#papa { left: -214px; width: 1024px; height: 600px; background: #336699 url('https://638183.freep.cn/638183/Pic/81/7036.jpg') no-repeat center/cover; box-shadow: 3px 3px 30px #000; position: relative; overflow: hidden; }
.mpic { position: absolute; width: 124px; height: 221px; right: -124px; bottom: -130px; }
#disc { position: absolute; width: 60px; height: 60px; right: 20px; bottom: 20px; background: conic-gradient(red,orange,yellow,green,teal,blue,purple); border-radius: 50%; mask: radial-gradient(transparent 4px,red 0); -webkit-mask: radial-gradient(transparent 4px,red 0); animation: rot 2s linear infinite; cursor: pointer; z-index: 100; }
@keyframes rot { to { transform: rotate(360deg); } }
@keyframes shot { from {transform: translate(0px, 0px) rotate(-45deg); } to { transform: translate(-1084px, -600px) rotate(-45deg); }}
</style>

<div id="papa"><span id="disc"></span></div>

<script>
let arr = , aud = new Audio();

aud.src = 'https://music.163.com/song/media/outer/url?id=1428166708.mp3';
aud.loop = true;
aud.autoplay = true;

disc.style.animationPlayState = aud.paused ? 'paused' : 'running';

for(x of arr) {
        let ele = document.createElement('img');
        ele.className = 'mpic';
        ele.src = 'https://638183.freep.cn/638183/Pic/81/tj.gif';
        ele.alt = '';
        ele.style.animation = 'shot 4s linear ' + x * .6 + 's infinite';
        papa.appendChild(ele);
}

disc.onclick = () => aud.paused ? aud.play() : aud.pause();
aud.addEventListener('playing',()=> disc.style.animationPlayState = 'running');
aud.addEventListener('pause',()=> disc.style.animationPlayState = 'paused');

</script>

加林森 发表于 2022-8-4 13:37

好有创意。真漂亮。{:4_199:}

马黑黑 发表于 2022-8-4 13:39

加林森 发表于 2022-8-4 13:37
好有创意。真漂亮。

关键是,代码不多。你也可以让你的鹰这么飞,不过要改个方向,你试试

加林森 发表于 2022-8-4 13:40

派老鹰出动也是这个效果吧。

加林森 发表于 2022-8-4 13:41

马黑黑 发表于 2022-8-4 13:39
关键是,代码不多。你也可以让你的鹰这么飞,不过要改个方向,你试试

我准备试一下。

梦油 发表于 2022-8-4 14:35

乘坐黑黑飞船遨游太空啦!绝妙的创意,完美的设计。————棒!

红影 发表于 2022-8-4 15:40

ele.style.animation = 'shot 4s linear ' + x * .6 + 's infinite';
这句的含义不明白。

制作很漂亮,这个图图和动图都好清晰,特别养眼{:4_187:}

樵歌 发表于 2022-8-4 16:32

马氏空天无敌战舰!

小辣椒 发表于 2022-8-4 17:07

上来看看的,果然黒黑有新分享,看看很复杂一样,手机不能自己电脑预览效果,晚上看看,早回家就套用一个{:4_189:}

小辣椒 发表于 2022-8-4 17:08

音乐很动感

小辣椒 发表于 2022-8-4 17:34

黒黑今天火箭出来了,配合前线打击分裂国家的台独分子

小辣椒 发表于 2022-8-4 19:37

电脑上来了,看看黑黑威武的火箭炮{:4_178:}

小辣椒 发表于 2022-8-4 19:37

谢谢黑黑分享,现在去套用一个试试



马黑黑 发表于 2022-8-4 20:04

小辣椒 发表于 2022-8-4 19:37
谢谢黑黑分享,现在去套用一个试试

挺好挺好

马黑黑 发表于 2022-8-4 20:05

加林森 发表于 2022-8-4 13:40
派老鹰出动也是这个效果吧。

可以比这个效果好

马黑黑 发表于 2022-8-4 20:05

小辣椒 发表于 2022-8-4 19:37
电脑上来了,看看黑黑威武的火箭炮

解气吧

马黑黑 发表于 2022-8-4 20:05

梦油 发表于 2022-8-4 14:35
乘坐黑黑飞船遨游太空啦!绝妙的创意,完美的设计。————棒!

喝茶{:4_180:}

加林森 发表于 2022-8-4 20:07

马黑黑 发表于 2022-8-4 20:05
可以比这个效果好

嗯嗯。我已经制作了一个出来。

马黑黑 发表于 2022-8-4 20:08

红影 发表于 2022-8-4 15:40
ele.style.animation = 'shot 4s linear ' + x * .6 + 's infinite';
这句的含义不明白。



这句,

ele.style.animation = 'shot 4s linear ' + x * .6 + 's infinite';

是通过JS来写CSS:调用动画 shot,4秒运行周期,匀速,x * 0.6 的延时(这样可以不同是出发),循环往复。
页: [1] 2
查看完整版本: 天际