-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndex.html
116 lines (115 loc) · 2.61 KB
/
Index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<!-- Created By CodingNepal -->
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Button Ripple Effect</title>
<style>
@import url('https://fonts.googleapis.com/css?family=Poppins:400,500,600,700&display=swap');
*{
margin: 0;
padding: 0;
outline: none;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
html,body{
display: grid;
height: 100%;
place-items: center;
text-align: center;
}
.wrapper{
background: #fff;
padding: 20px 30px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.25);
}
.wrapper .text{
font-size: 35px;
font-weight: 600;
}
.wrapper p{
font-size: 20px;
font-weight: 500;
line-height: 20px;
}
.wrapper .btns{
display: flex;
margin: 30px 0 20px 0;
}
.btns a{
position: relative;
margin: 0 20px;
height: 60px;
width: 200px;
display: block;
line-height: 60px;
border-radius: 30px;
text-decoration: none;
color: #fff;
font-size: 18px;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 1px;
overflow: hidden;
box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.btns a:first-child{
background: linear-gradient(-90deg, #f5ce62, #e85a19);
}
.btns a:last-child{
background: linear-gradient(90deg, #0162c8, #55e7fc);
}
.btns a > span{
position: absolute;
background: #fff;
transform: translate(-50%, -50%);
border-radius: 50%;
pointer-events: none;
animation: ripples 0.6s linear infinite;
}
@keyframes ripples {
0% {
width: 0px;
height: 0px;
opacity: 0.5;
}
100% {
width: 500px;
height: 500px;
opacity: 0;
}
}
</style>
</head>
<body>
<div class="wrapper">
<div class="text">
Button Ripple Effect
</div>
<p>
using HTML CSS & JavaScript
</p>
<div class="btns">
<a href="#">Click me</a>
<a href="#">Click me</a>
</div>
</div>
<script>
const buttons = document.querySelectorAll("a");
buttons.forEach((button) => {
button.onclick = function(e){
let x = e.clientX - e.target.offsetLeft;
let y = e.clientY - e.target.offsetTop;
let ripple = document.createElement("span");
ripple.style.left = `${x}px`;
ripple.style.top = `${y}px`;
this.appendChild(ripple);
setTimeout(function(){
ripple.remove();
}, 600); // 1second = 1000ms
}
});
</script>
</body>
</html>