首页 技术 正文
技术 2022年11月6日
0 收藏 893 点赞 842 浏览 1875 个字

我是波浪,我有起伏,我有大波与小波(坏笑中…)

  最近改版网站,一般也不会去写动画,但是有些网站还是需要的,故拿出一个较简单的动画出来分享,很简单很简单。

原理简单阐述

  其实很简单,使用一张美工做好了的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>

好咯,代码附送完毕。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,117
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,589
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,435
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,206
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,842
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,927