首页 技术 正文
技术 2022年11月7日
0 收藏 476 点赞 457 浏览 2289 个字

今天要为大家绍一款由jquery实现的鼠标单击出现水波特效。用鼠标猛点击页面,你可以看到页面不断出面水波纹效果。然后水波纹渐渐消失。效果非常不错。我们一起看下效果图:

一款基于jquery实现的鼠标单击出现水波特效

在线预览   源码下载

实现的代码。

html代码:

 <div id="container">
<h1>
Click or Touch the Screen.</h1>
<p>
Click as fast as you can. <em>Try it on a touchscreen - it's even more fun.</em></p>
</div>

css代码:

  * {
user-select: none;
cursor: default;
}body, html {
height: 100%;
font-family: helvetica neue,helvetica,arial,sans-serif;
}h1, p {
text-align: center;
position: relative;
z-index:;
}h1 {
padding: 50px 0;
margin: 0 50px;
font-size: 30px;
line-height: 30px;
font-weight:;
}p {
font-size: 14px;
font-weight:;
margin: 0 50px;
color: #53646e;
}
p em {
color: #42a6df;
}#container {
position: relative;
height: 100%;
width: 100%;
overflow: hidden;
}
#container button {
padding: 20px;
border: none;
background: transparent;
display: block;
position: relative;
z-index:;
margin: 0 auto;
}.dot {
height: 2px;
width: 2px;
border-radius: 100%;
position: absolute;
z-index:;
animation: sploosh 3s cubic-bezier(0.165, 0.84, 0.44, 1);
background: transparent;
}@keyframes sploosh {
0% {
box-shadow: 0 0 0 0px rgba(66, 166, 223, 0.7);
background: rgba(66, 166, 223, 0.7);
}
100% {
box-shadow: 0 0 0 300px rgba(66, 166, 223, 0);
background: rgba(66, 166, 223, 0);
}
}

js代码:

  $(window).ready(function () {
setTimeout(function () {
setTimeout(function () {
$('#container').append('<div class="dot" style="top:50%;left:50%;"></div>')
}, 900);
setTimeout(function () {
$('#container').append('<div class="dot" style="top:50%;left:50%;"></div>')
}, 600);
setTimeout(function () {
$('#container').append('<div class="dot" style="top:50%;left:50%;"></div>')
}, 300);
setTimeout(function () {
$('#container').append('<div class="dot" style="top:50%;left:50%;"></div>')
}, 0);
setTimeout(function () {
$('#container .dot').remove();
}, 2900);
}, 1500);
}); // click animation if (Modernizr.touch) {
$('#container').on('touchstart', function (e) {
var left = e.originalEvent.touches[0].pageX;
var top = e.originalEvent.touches[0].pageY; $(this).append('<div class="dot" style="top:' + top + 'px;left:' + left + 'px;"></div>')
setTimeout(function () {
$('#container .dot:first-of-type').remove();
}, 3000);
});
document.body.addEventListener('touchmove', function (e) {
e.preventDefault();
});
} else {
$('#container').on('mousedown', function (e) {
var left = e.pageX;
var top = e.pageY; $(this).append('<div class="dot" style="top:' + top + 'px;left:' + left + 'px;"></div>')
setTimeout(function () {
$('#container .dot:first-of-type').remove();
}, 3000);
});
} //@ sourceURL=pen.js

注:本文爱编程原创文章,转载请注明原文地址:http://www.w2bc.com/Article/6909

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