CSS3 波浪簡單類比--我是波浪,我有起伏,有大波與小波(壞笑中...),

來源:互聯網
上載者:User

CSS3 波浪簡單類比--我是波浪,我有起伏,有大波與小波(壞笑中...),
我是波浪,我有起伏,我有大波與小波(壞笑中...)

  最近改版網站,一般也不會去寫動畫,但是有些網站還是需要的,故拿出一個較簡單的動畫出來分享,很簡單很簡單。

 

原理簡單闡述

  其實很簡單,使用一張美工做好了的2400px寬度的3個不同起伏的波浪,然後自己合成為一張【精靈圖片】(有助於一起加速載入和同時載入)

有了素材就好辦了,使用一個容器把3個div背景的波浪堆在一起,然後使用css3的位移進行移動,當然左右和上下都要,然後慢慢調整為一個適合的時間和延遲。

 

廢話不多說,先上示範地址:http://sandbox.runjs.cn/show/akodn0vt

 

波浪動畫CSS
<style type="text/css">        /* *  author: jasnature *  email : 276227015@qq.com *  last update : 2016-04-21 * */        .index_waves {            background: url("img/index_waves.png  這裡放波浪圖,圖可以去示範地址摳出來") center 0 no-repeat;        }                .wave3 {            height: 427px;            width: 2402px;            background-position: 0 0;        }                .wave2 {            height: 427px;            width: 2402px;            background-position: 0 -427px;        }                .wave1 {            height: 427px;            width: 2402px;            background-position: 0 -854px;        }                @keyframes wave {            0% {                transform: translate(0px, 0px);            }            50% {                transform: translate(-80px, 30px);            }            100% {                transform: translate(160px, -60px);            }        }                @-webkit-keyframes wave {            0% {                transform: translate(0px, 0px);            }            50% {                transform: translate(-80px, 30px);            }            100% {                transform: translate(160px, -60px);            }        }                @-moz-keyframes wave {            0% {                transform: translate(0px, 0px);            }            50% {                transform: translate(-80px, 30px);            }            100% {                transform: translate(160px, -60px);            }        }                .waves {            position: absolute;            bottom: -135px;            height: 527px;            width: 100%;            overflow: hidden;        }                .waves > div {            position: absolute;            left: -180px;            bottom: 0;        }                .waves .wave1,        .waves .wave2,        .waves .wave3 {            animation: wave 5s ease-in-out alternate infinite;        }                .waves .wave2 {            animation-delay: 0.6s;        }                .waves .wave3 {            animation-delay: 1.2s;        }                .waveContent {            position: relative;            background-color: #219df3;            height: 500px;        }                h2 {            position: relative;            display: block;            color: #fff;            font-size: 48px;            font-family: "microsoft yahei";            font-weight: normal;            width: 1100px;            margin: 0 auto;            top: 180px;            z-index: 99;        }    </style>

 

波浪動畫HTML

 

<!DOCTYPE html><html>    <head>        <meta charset="UTF-8">        <title>我是波浪,我有起伏,我有大波與小波(壞笑中...)</title>    </head>        <body>        <div class="waveContent">            <h2>我是波浪,我有起伏,我有大波與小波(壞笑中...)</h2>            <div class="waves">                <div class="index_waves wave1">                </div>                <div class="index_waves wave2">                </div>                <div class="index_waves wave3">                </div>            </div>        </div>    </body></html>

 

 

好咯,代碼附送完畢。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.