Created
January 13, 2020 07:07
-
-
Save giangmd/018c8b91a889381418c9c4c1e27125c7 to your computer and use it in GitHub Desktop.
Create ripple effect with CSS only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Create ripple effect with CSS only</title> | |
<style> | |
.container { | |
background-color: #ffffff; | |
height: 500px; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
} | |
.btn { | |
background-color: orange; | |
color: #fff; | |
font-size: 40px; | |
padding: 20px 20px; | |
} | |
/*ripple effect*/ | |
.ripple { | |
position: relative; | |
overflow: hidden; | |
transform: translate3d(0, 0, 0); | |
} | |
.ripple:after { | |
content: ""; | |
display: block; | |
position: absolute; | |
width: 100%; | |
height: 100%; | |
top: 0; | |
left: 0; | |
pointer-events: none; | |
background-image: radial-gradient(circle, #fff 10%, transparent 10.01%); | |
background-repeat: no-repeat; | |
background-position: 50%; | |
transform: scale(10, 10); | |
opacity: 0; | |
transition: transform .5s, opacity 1s; | |
} | |
.ripple:active:after { | |
transform: scale(0, 0); | |
opacity: .3; | |
transition: 0s; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<button class="btn ripple">Click here</button> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment