@erichsia7/ripple
Version:
Add ripple effect to anything
101 lines (89 loc) • 2.48 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>ripple.js</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;500;700&display=swap" rel="stylesheet">
<style>
.btn {
width: 100px;
height: 55px;
border-radius: 99em;
display: flex;
justify-content: center;
align-items: center;
font-size: 23px;
font-weight: 500;
font-family: 'Noto Sans TC', sans-serif;
margin-top: 30px;
}
#b1 {
background: #fafafa;
color: #1082af;
}
#b2 {
background: #1082af;
color: #fff;
}
h1 {
font-weight: 700;
font-family: 'Noto Sans TC', sans-serif;
text-align: center;
margin-top: 80px;
}
p {
font-weight: 500;
font-family: 'Noto Sans TC', sans-serif;
text-align: center;
}
#github {
position: fixed;
right: 10px;
bottom: 10px;
width: 55px;
height: 55px;
border-radius: 99em;
display: flex;
justify-content: center;
align-items: center;
margin-top: 30px;
background: url(github.png);
background-size: 55px 55px;
background-position: center;
}
#d1 {
width: 200px;
height: 200px;
border-radius: 15px;
background: #f5f5f5;
display: flex;
justify-content: center;
align-items: center;
font-weight: 500;
font-family: 'Noto Sans TC', sans-serif;
position: relative;
left: 50%;
transform: translateX(-50%);
}
</style>
</head>
<body>
<h1>ripple.js</h1>
<p>Add ripple effect to elements.</p>
<div id="d1">
Click here.
</div>
<div class="btn" style="position:relative;left:50%;transform:translateX(-50%)" id="b1">button1</div>
<div class="btn" style="position:relative;left:50%;transform:translateX(-50%)" id="b2" onclick="alert('button2')">button2</div>
<div id="github" onclick="window.open('https://github.com/EricHsia7/ripple.js')"></div>
</body>
<script src="https://unpkg.com/@erichsia7/ripple@latest/dist/index.min.js"></script>
<script>
ripple.addTo('#b1', '#1082af', 800);
ripple.addTo('#b2,#github', '#fff', 450);
ripple.addTo('#d1', '#000', 450);
</script>
</html>