jQuery点击水纹波动动画原理:
1.在需要实现水波纹效果的标签中添加
2.代码会定位 鼠标相对 与 标签的位置,以鼠标点为圆心画圆
3.圆的半径 可以自定义(默认为标签的最大宽或高度)
4.圆点颜色,和动画时间等可以自行修改内部代码,或直接 调用 $().css({})方法 进行覆盖
ripple-wrapper.js
$(function(){
$(".ripple-wrapper").css(
{
"position": " absolute",
"top": " 0",
"left": " 0",
"z-index": " 1",
"width": " 100%",
"height": " 100%",
"overflow": " hidden",
"border-radius": " inherit",
"pointer-events": " none"
});
$(".ripple-wrapper").parent().click(function(e){
var ripple_obj=$(this).find(".ripple-wrapper");
if(ripple_obj.find("div").length){ripple_obj.find("div").remove();}
ripple_obj.prepend("");
var ripple_div=ripple_obj.find("div");
ripple_div.css(
{
"display": " block",
"background": " rgba(255, 255, 255, 0.7)",
"border-radius": " 50%",
"position": " absolute",
"-webkit-transform": " scale(0)",
"transform": " scale(0)",
"opacity": " 1",
"transition": " all 0.7s",
"-webkit-transition": " all 0.7s",
"-moz-transition": " all 0.7s",
"-o-transition": " all 0.7s",
"z-index": " 1",
"overflow": " hidden",
"pointer-events": " none"
});
var R= parseInt(ripple_obj.outerWidth());
if(parseInt(ripple_obj.outerWidth())
HTML
document
.ck {
cursor: pointer;
display: block;
padding: 1em;
text-decoration: none;
width: 200px;
height: 20px;
position: relative;
overflow: hidden;
color: #fff;
}
点一下
演示图
未封装代码
document
.ck {
background: #ffab91;
display: block;
padding: 1em;
text-decoration: none;
width: 200px;
height: 20px;
position: relative;
overflow: hidden;
}
.ck .bd {
background: rgba(0, 0, 0,0.8);
border-radius: 50%;
width: 0px;
height: 0px;
position: absolute;
-webkit-transform: scale(0);
transform: scale(0);
opacity: 1;
}
.dh {
animation: ldm 0.8s ;
-moz-animation: ldm 0.8s ;
-o-animation: ldm 0.8s ;
-webkit-animation: ldm 0.8s ;
}
@-webkit-keyframes ldm {
100% {
-webkit-transform: scale(1);
opacity: 0
}
}
@keyframes ldm {
100% {
-webkit-transform: scale(1);
opacity: 0
}
}
adasdsd



