纯 CSS 创作出平滑的层叠海浪特效

站长手记 作者: 2024-08-28 02:50:01
这里的波浪只是侧面的,利用几个平面一部分弧旋转得到。定义 dom,容器中包含一行文本和3条做海浪特效的 ,设置容器,文字样式,制作海浪动画效果

代码解读

<div class="sea">
    <p class="title">the sea</p>
    <span class="wave"></span>
    <span class="wave"></span>
    <span class="wave"></span>
</div>
html, body {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(antiquewhite, navajowhite);
}
.sea {
    width: 300px;
    height: 300px;
    background-color: whitesmoke;
    background-image: linear-gradient(
        darkblue,
        rgba(255, 255, 255, 0) 80%,
        rgba(255, 255, 255, 0.5));
    border-radius: 5px;
    box-shadow: 0 2px 30px rgba(0, 0, 0, 0.2);
}
.sea {
    position: relative;
}

.sea .title {
    color: white;
    font-size: 24px;
    font-family: serif;
    text-align: center;
    line-height: 250px;
    text-transform: uppercase;
    letter-spacing: 0.4em;
    position: absolute;
    z-index: 1;
    width: 100%;
}
.sea .wave {
    position: absolute;
    top: -250px;
    left: -100px;
    width: 500px;
    height: 500px;
    background: deepskyblue;
    border-radius: 43%;
    filter: opacity(0.4);
    animation: drift linear infinite;
}

.sea .wave:nth-of-type(1) {
    animation-duration: 5s;
}

.sea .wave:nth-of-type(2) {
    animation-duration: 7s;
}

.sea .wave:nth-of-type(3) {
    animation-duration: 9s;
}

@keyframes drift {
    from {
        transform: rotate(360deg);
    }
}
.sea .wave {
    transform-origin: 50% 48%;
}

.sea .wave:nth-of-type(3) {
    background-color: orangered;
    filter: opacity(0.1);
}
.sea {
    overflow: hidden;
}
实现效果:https://codepen.io/comehope/pen/JvmBdE
来自:https://segmentfault.com/a/1190000014895634
原创声明
本站部分文章基于互联网的整理,我们会把真正“有用/优质”的文章整理提供给各位开发者。本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
本文链接:http://www.jiecseo.com/news/show_69890.html
CSS 海浪特效