網頁展示水波紋效果 css水波效果

網頁展示水波紋效果

預覽

預覽

思路

在頁面底部展示多張水波的圖片,然後讓每張水波以不同的方向和速度進行移動,並給不同的水波設置不同的透明度。

代碼

HTML index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="style.css">
    <title>WaterWaveAnimation</title>
</head>
<body>
    <section>
        <div class="wave wave1"></div>
        <div class="wave wave2"></div>
        <div class="wave wave3"></div>
        <div class="wave wave4"></div>
    </section>
</body>
</html>

CSS style.css

* {
    margin: 0;
    padding: 0;
}

section {
    position: relative;
    width: 100%;
    height: 100vh;
    background: #3586ff;
    overflow: hidden;
}

section .wave {
    width: 100%;
    height: 100px;
    position: absolute;
    bottom: 0;
    left: 0;
    background: url(wave.png);
    background-size: 1000px 100px;
}

section .wave.wave1 {
    animation: animate1 20s linear infinite;
    z-index: 1000;
    opacity: 1;
    animation-delay: 0s;
    bottom: 0;
}

section .wave.wave2 {
    animation: animate2 15s linear infinite;
    z-index: 999;
    opacity: 0.5;
    animation-delay: -5s;
    bottom: 10px;
}

section .wave.wave3 {
    animation: animate1 10s linear infinite;
    z-index: 998;
    opacity: 0.2;
    animation-delay: -7s;
    bottom: 15px;
}

section .wave.wave4 {
    animation: animate2 2s linear infinite;
    z-index: 997;
    opacity: 0.71;
    animation-delay: -5s;
    bottom: 20px;
}
    
@keyframes animate1 {
    0% {
        background-position-x: 0;
    }
    100% {
        background-position-x: 1000px;
    }
}

@keyframes animate2 {
    0% {
        background-position-x: 0;
    }
    100% {
        background-position-x: -1000px;
    }
}

圖片資源請到Github中下載

github地址

https://github.com/djzhao627/WaterWaveAnimation-CSS

參考地址:

https://www.youtube.com/watch?v=MMNEEdGa5eE

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章