<a href="#" class="button btn1">
<span>Hey, click me</span>
</a>
<a href="#" class="button btn2">
<span>No click me!</span>
</a>
<a href="#" class="button btn3">
<span>Click me please</span>
<div class="ripple-effect"></div>
</a>
<a href="#" class="button btn4">
<span>You, click me</span>
<div class="ripple-effect"></div>
</a>
<label><input type="checkbox"> Enable fade</label>
$primary-color: #1E88E5;
$secondary-color: white;
$button-standard-width: 250px;
body {
text-align: center;
font-family: 'Roboto', sans-serif;
background-image: url(https://i.imgur.com/kawGZC6.jpg);
background-size: cover;
background-position: top center;
height: 100vh;
padding-top: 25vh;
box-sizing: border-box;
@media (max-width: 560px) {
background-size: auto 140%;
padding-top: 20vh;
}
}
.button {
display: inline-block;
margin: 0 10px 20px;
color: $primary-color;
border: 2px solid $primary-color;
border-radius: 4px;
text-transform: uppercase;
font-size: 22px;
font-weight: 500;
text-decoration: none;
padding: 15px 40px;
position: relative;
overflow: hidden;
&:before {
content: '';
display: block;
position: absolute;
}
span {
position: relative;
z-index: 1;
}
}
.btn1 {
transition: color 0.3s 0.1s ease-out;
&:before {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border-radius: 50%;
width: $button-standard-width;
height: $button-standard-width;
box-shadow: inset 0 0 0 0 $primary-color;
transition: box-shadow 0.5s ease-out;
}
&.fade:before {
box-shadow: none;
}
&.active {
color: $secondary-color;
&:before {
box-shadow: inset 0 0 0 $button-standard-width $primary-color;
}
}
}
.btn2 {
transition: color 0.4s ease;
&:before {
top: 50%;
left: 50%;
transform: translate3d(-50%, -50%, 0) scale(0);
border-radius: 50%;
background-color: $primary-color;
width: 250px;
height: 250px;
opacity: 1;
transition: all 0.4s ease;
}
&.fade:before {
opacity: 0;
}
&.active {
color: $secondary-color;
&:before {
opacity: 1;
transform: translate3d(-50%, -50%, 0) scale(1);
}
}
}
.btn3 {
transition: color 0.4s ease;
.ripple-effect {
position: absolute;
transform: scale(0) translateZ(0);
border-radius: 50%;
background: $primary-color;
width: $button-standard-width;
height: $button-standard-width;
opacity: 1;
transition: transform 0.5s ease, opacity 0.5s ease;
}
&.fade .ripple-effect {
opacity: 0;
}
&.active {
color: $secondary-color;
.ripple-effect {
opacity: 1;
transform: scale(2.5) translateZ(0);
}
}
}
.btn4 {
transition: color 0.2s ease-out;
.ripple-effect {
position: absolute;
border-radius: 50%;
width: $button-standard-width * 2;
height: $button-standard-width * 2;
box-shadow: inset 0 0 0 0 $primary-color;
transition: box-shadow 0.3s ease-out;
}
&.fade .ripple-effect {
box-shadow: none;
}
&.active {
color: $secondary-color;
.ripple-effect {
box-shadow: inset 0 0 0 $button-standard-width $primary-color;
}
}
}
label {
position: absolute;
display: block;
top: 0;
right: 0;
padding: 15px;
user-select: none;
input {
transform: translateY(1px);
}
}
View Compiled
(function ( $ ) {
$.fn.ripplePosition = function(e) {
var x = e.pageX - this.parent().offset().left - this.width()/2;
var y = e.pageY - this.parent().offset().top - this.height()/2;
this.css({
top: y + 'px',
left: x + 'px'
});
return this;
};
}( jQuery ));
$('.button').on('click', function(e){
var $button = $(this);
var $ripple = $button.children('.ripple-effect');
if($ripple.length > 0) {
$ripple.ripplePosition(e);
}
$button.addClass('active');
setTimeout(function(){
$button.removeClass('active');
}, 2000);
});
$('label input[type="checkbox"]').on('change', function(){
$('.button').toggleClass('fade');
});