HTML CSS JS Wave绘制和动画

时间:2018-08-09 15:40:44

标签: javascript html css animation

我正在开发一个Ionic跨平台移动应用程序,并且已经完成了基本的设计和布局。但是,我想实现一些引人注目的设计元素,即某些页面上的“波浪效果”。

第一部分 是在屏幕上绘制波浪。 我在Photoshop中模拟的设计如下。

enter image description here

“波效应”是指波浪线,它们是纯白色底部和顶部黄色部分之间逐渐增加的透明线。

在这种情况下,有4个重叠的波,每个波的不透明度为25%,最终在底部有100%的白色不透明度。

如果可能的话,我也希望它们在圆形的粉红色+按钮处相交。但这将是一个“不错”的功能。

其次 ,我将如何对波浪进行动画处理以在例如单击按钮? 这个想法是,当用户单击粉色+按钮时,波浪将向上移动以显示下面的更多UI。 类似于THIS效果。

我什至不知道Google会称它为什么。 我已经搜索过波或正弦波,但是没有类似的东西。

2 个答案:

答案 0 :(得分:2)

您可以创建类似波浪的图像,并使用CSS将其设置为以各种速率平移和缩放。像四张图像以不同速率缩放和平移之类的东西应该能够给人以错觉。

@keyframes move_wave {
    0% {
        transform: translateX(0) translateZ(0) scaleY(1)
    }
    50% {
        transform: translateX(-25%) translateZ(0) scaleY(0.55)
    }
    100% {
        transform: translateX(-50%) translateZ(0) scaleY(1)
    }
}
.waveWrapper {
    overflow: hidden;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    margin: auto;
}
.waveWrapperInner {
    position: absolute;
    width: 100%;
    overflow: hidden;
    height: 100%;
    bottom: -1px;
    background-image: linear-gradient(to top, #86377b 20%, #27273c 80%);
}
.bgTop {
    z-index: 15;
    opacity: 0.5;
}
.bgMiddle {
    z-index: 10;
    opacity: 0.75;
}
.bgBottom {
    z-index: 5;
}
.wave {
    position: absolute;
    left: 0;
    width: 200%;
    height: 100%;
    background-repeat: repeat no-repeat;
    background-position: 0 bottom;
    transform-origin: center bottom;
}
.waveTop {
    background-size: 50% 100px;
}
.waveAnimation .waveTop {
  animation: move-wave 3s;
   -webkit-animation: move-wave 3s;
   -webkit-animation-delay: 1s;
   animation-delay: 1s;
}
.waveMiddle {
    background-size: 50% 120px;
}
.waveAnimation .waveMiddle {
    animation: move_wave 10s linear infinite;
}
.waveBottom {
    background-size: 50% 100px;
}
.waveAnimation .waveBottom {
    animation: move_wave 15s linear infinite;
}
<div class="waveWrapper waveAnimation">
    <div class="waveWrapperInner bgTop">
        <div class="wave waveTop" style="background-image: url('http://front-end-noobs.com/jecko/img/wave-top.png')"></div>
    </div>
    <div class="waveWrapperInner bgMiddle">
        <div class="wave waveMiddle" style="background-image: url('http://front-end-noobs.com/jecko/img/wave-mid.png')"></div>
    </div>
    <div class="waveWrapperInner bgBottom">
        <div class="wave waveBottom" style="background-image: url('http://front-end-noobs.com/jecko/img/wave-bot.png')"></div>
    </div>
</div>

请尝试以下链接以供参考:

  1. Css Wave Animation

  2. PNG Wave Animation

  3. waves-animation github

搜索html wave动画也会得到非常有趣的结果。

答案 1 :(得分:-1)

在我们的一个项目中,为了完成与您所描述的类似的工作,我们设计了4种具有不同不透明度的gif文件,并将它们设置为彼此之间的背景。他们看起来很不错,但是移动设备确实变慢了!