逃离
<style>#tz {
margin: 30px 0px 30px calc(50% - 721px);
width: 1280px;
height: 600px;
background: blue url('https://638183.freep.cn/638183/t24/4/escape.jpg') no-repeat center/cover;
box-shadow: 3px 3px 6px rgba(0,0,0,.6);
position:relative;
}
#player {
position: absolute;
bottom: 20px;
left: calc(50% - 50px);
animation: rot 8s linear infinite var(--state);
}
.waves {
position: absolute;
bottom: 0;
width: 100%;
height: 50%;
}
.wavegroup > use {
animation: waving 25s cubic-bezier(.55,.5,.45,.5) infinite var(--state);
}
.wavegroup > use:nth-child(1) {
animation-delay: -2s;
animation-duration: 7s;
}
.wavegroup > use:nth-child(2) {
animation-delay: -3s;
animation-duration: 10s;
}
.wavegroup > use:nth-child(3) {
animation-delay: -4s;
animation-duration: 13s;
}
.wavegroup > use:nth-child(4) {
animation-delay: -5s;
animation-duration: 30s;
}
@keyframes waving {
0% { transform: translate3d(-90px,0,0); }
100% { transform: translate3d(85px,0,0); }
}
@keyframes rot {
to { transform: rotate(360deg); filter: hue-rotate(360deg); }
}
</style>
<div id="tz">
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=1397231580" autoplay loop></audio>
<svg class="waves" viewBox="0 24 150 28" xmlns="http://www.w3.org/2000/svg">
<defs>
<path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z" />
</defs>
<g class="wavegroup">
<use xlink:href="#gentle-wave" x="48" y="0" fill="rgba(255,255,255,0.4" />
<use xlink:href="#gentle-wave" x="48" y="3" fill="rgba(255,255,255,0.3)" />
<use xlink:href="#gentle-wave" x="48" y="5" fill="rgba(255,255,255,0.2)" />
<use xlink:href="#gentle-wave" x="48" y="7" fill="rgba(255,255,255,0.1" />
</g>
</svg>
<img id="player" src="https://638183.freep.cn/638183/web/svg/p2.svg" atl="" title="play" />
</div>
<script>
mState = () => {
tz.style.setProperty('--state', aud.paused ? 'paused' : 'running');
player.title = aud.paused ? '点击播放' : '点击暂停';
};
aud.onplaying = aud.onpause = () => mState();
player.onclick = () => aud.paused ? aud.play() : aud.pause();
</script>
<h2>帖子代码</h2>
<div class="hE"><pre>
<style>
#tz {
margin: 30px 0px 30px calc(50% - 721px);
width: 1280px;
height: 600px;
background: blue url('https://638183.freep.cn/638183/t24/4/escape.jpg') no-repeat center/cover;
box-shadow: 3px 3px 6px rgba(0,0,0,.6);
position:relative;
}
#player {
position: absolute;
bottom: 20px;
left: calc(50% - 50px);
animation: rot 8s linear infinite var(--state);
}
.waves {
position: absolute;
bottom: 0;
width: 100%;
height: 50%;
}
.wavegroup > use {
animation: waving 25s cubic-bezier(.55,.5,.45,.5) infinite var(--state);
}
.wavegroup > use:nth-child(1) {
animation-delay: -2s;
animation-duration: 7s;
}
.wavegroup > use:nth-child(2) {
animation-delay: -3s;
animation-duration: 10s;
}
.wavegroup > use:nth-child(3) {
animation-delay: -4s;
animation-duration: 13s;
}
.wavegroup > use:nth-child(4) {
animation-delay: -5s;
animation-duration: 30s;
}
@keyframes waving {
0% { transform: translate3d(-90px,0,0); }
100% { transform: translate3d(85px,0,0); }
}
@keyframes rot {
to { transform: rotate(360deg); filter: hue-rotate(360deg); }
}
</style>
<div id="tz">
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=1397231580" autoplay loop></audio>
<svg class="waves" viewBox="0 24 150 28" xmlns="http://www.w3.org/2000/svg">
<defs>
<path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z" />
</defs>
<g class="wavegroup">
<use xlink:href="#gentle-wave" x="48" y="0" fill="rgba(255,255,255,0.4" />
<use xlink:href="#gentle-wave" x="48" y="3" fill="rgba(255,255,255,0.3)" />
<use xlink:href="#gentle-wave" x="48" y="5" fill="rgba(255,255,255,0.2)" />
<use xlink:href="#gentle-wave" x="48" y="7" fill="rgba(255,255,255,0.1" />
</g>
</svg>
<img id="player" src="https://638183.freep.cn/638183/web/svg/p2.svg" atl="" title="play" />
</div>
<script>
mState = () => {
tz.style.setProperty('--state', aud.paused ? 'paused' : 'running');
player.title = aud.paused ? '点击播放' : '点击暂停';
};
aud.onplaying = aud.onpause = () => mState();
player.onclick = () => aud.paused ? aud.play() : aud.pause();
</script>
</pre></div>
<script>
var sc = document.createElement('script');
sc.chartset = 'utf-8';
sc.src = 'https://638183.freep.cn/638183/web/js2024/helight.js';
document.body.appendChild(sc);
</script>
相当别致,欣赏学习了{:4_204:} 问好老师,欣赏 学习!{:4_187:} 问老师,波浪形不是MP4? 梦江南 发表于 2024-10-8 14:23
问老师,波浪形不是MP4?
这个帖子没有视频 马黑黑 发表于 2024-10-8 17:32
这个帖子没有视频
我的天。。。这波浪效果跟视频也差不多了吧。。。太逼真了。。{:4_187:} 前面只顾看到玉镯的渐变通透靓丽,色彩梦幻。。。绝美之极。。没想到还有更高级的波浪。。等会要仔仔细细研究一下代码{:4_187:} 看了一下大概明白原理,
先绘制animation: waving 25s cubic-bezier(.55,.5,.45,.5)贝塞尔曲线,
又复制出4条,并设置每一条的不同的延迟时间不相同,每一条运动的总时长也不相同,
从-90PX,移动到80PX位置,
由于弧的位置在左右移动,形成源源不断的波浪起伏效果{:4_199:} 为了营造不同的层次效果,填充色还给了四个不同的透明度,分别是0.1~0.4,
这个设计太妙了,换成别的颜色也非常好看。。
可以整成纱帘一样的效果。{:4_199:} 跟波浪相比,小播到是简单了,
用了制好的SVG图片,
动态中给了个色相hue-rotate(360deg);
只看效果当属绝佳,
这贴子的构思太妙~~{:4_173:} 花飞飞 发表于 2024-10-8 20:35
跟波浪相比,小播到是简单了,
用了制好的SVG图片,
动态中给了个色相hue-rotate(360deg);
{:4_190:} 花飞飞 发表于 2024-10-8 20:31
为了营造不同的层次效果,填充色还给了四个不同的透明度,分别是0.1~0.4,
这个设计太妙了,换成别的颜色 ...
这个我也想到了 花飞飞 发表于 2024-10-8 19:44
我的天。。。这波浪效果跟视频也差不多了吧。。。太逼真了。。
还不错 朵拉 发表于 2024-10-8 12:36
相当别致,欣赏学习了
{:4_190:} 马黑黑 发表于 2024-10-8 20:50
中午匆忙一看,完全没get到重点。还是得要沉下心来细读。。{:4_170:} 马黑黑 发表于 2024-10-8 20:51
这个我也想到了
{:4_173:}关键是路径的设计吧。
<path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z" />
这个就很高级,波浪的形状是它决定的。。 马黑黑 发表于 2024-10-8 20:51
还不错
如果想让波浪覆盖的高一些,
把height: 50%;改大一些就好了,
不过即使取到100,上方好象还是有空间 马黑黑 发表于 2024-10-8 20:51
这个我也想到了
还有为了高度变化,四个Y值 设的也是不一样的,0357,加上透明 度,所以感觉层次更加丰富{:4_170:} 纯粹是大佬闲时闲作,为白老师的构思和创意惊叹一番, 这个新效果真是太喜欢了。。{:4_199:}