Skip to content

Instantly share code, notes, and snippets.

@koshdnb
Created September 5, 2014 16:07
Show Gist options
  • Select an option

  • Save koshdnb/7f5a12a8140066622195 to your computer and use it in GitHub Desktop.

Select an option

Save koshdnb/7f5a12a8140066622195 to your computer and use it in GitHub Desktop.
A Pen by Manar.
<a href="#" class="btn"></a>
<a href="#" class="btn"></a>
<a href="#" class="btn"></a>
$('.btn').on('mousedown', function(e){
e.preventDefault();
var $this = $(this),
offset = $this.offset(),
offsetY = (e.pageY - offset.top),
offsetX = (e.pageX - offset.left);
$this.addClass('clicked').append(
$('<span class="btn-circle"></span>')
.css({
'top' : offsetY,
'left' : offsetX
})
);
}).on('mouseup mouseout', function(e){
e.preventDefault();
var $this = $(this);
$this.removeClass('clicked')
.children().fadeOut(function(){
$(this).remove();
});
});
.btn {
position: relative;
display: block;
background: #FFF;
width: 200px;
height: 80px;
border-radius: 2px;
margin: 10px auto;
overflow: hidden;
-webkit-box-shadow: 0 2px 5px 1px rgba(0, 0, 0, 0.2);
box-shadow: 0 2px 5px 1px rgba(0, 0, 0, 0.2);
-webkit-transition: all 0.25s cubic-bezier(0.2, 0.7, 0.4, 1);
transition: all 0.25s cubic-bezier(0.2, 0.7, 0.4, 1);
}
.btn.clicked {
-webkit-box-shadow: 0 5px 10px 2px rgba(0, 0, 0, 0.3);
box-shadow: 0 5px 10px 2px rgba(0, 0, 0, 0.3);
}
.btn-circle {
display: block;
position: absolute;
background: #999;
width: 200px;
height: 200px;
margin-top: -100px;
margin-left: -100px;
border-radius: 50%;
opacity: 0.25;
-webkit-animation: btn-circle 0.5s ease-in forwards;
animation: btn-circle 0.5s ease-in forwards;
}
body {
margin: 50px 0;
padding: 0;
background: #F9F9F9;
}
h1 {
font-size: 2.5em;
color: rgba(249, 249, 249, 0.7);
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2), 0 1px 0 rgba(255, 255, 255, 0.1);
text-align: center;
text-transform: uppercase;
margin-bottom: 50px;
}
@-webkit-keyframes btn-circle {
0% {
-webkit-transform: scale(0);
transform: scale(0);
}
100% {
-webkit-transform: scale(3);
transform: scale(3);
}
}
@keyframes btn-circle {
0% {
-webkit-transform: scale(0);
transform: scale(0);
}
100% {
-webkit-transform: scale(3);
transform: scale(3);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment