JSFiddle - React, Tailwind, and code Playground

by shapeshifta

HTML

<button class="btn btn-secondary">Hotel suchen</button>
<button class="btn btn-secondary">Hotel suchen</button>
<button class="btn btn-secondary">Hotel suchen</button>
<button class="btn btn-secondary">Hotel suchen</button>

CSS

:focus {
    outline:none;
}
::-moz-focus-inner {
    border:0;
}
.btn {
    display:block;
    margin:2% 10%;
    text-align:center;
    color:#fff;
    text-decoration:none;
    position:relative;
    overflow:hidden;
    -webkit-transition: all 0.2s ease;
    -moz-transition: all 0.2s ease;
    -o-transition: all 0.2s ease;
    transition: all 0.2s ease;
    z-index:0;
    background: #f39200;
    border: 1px solid #ea8d01;
    border-radius: 4px;
    text-shadow: 1px 1px 1px #a66400;
    padding: 10px 20px;
    cursor: pointer;
    font-size:120%;
    outline: 0;
}
.btn:hover {
    z-index:1000;
    background: #ef8228;
}
.ink {
    display: block;
    position: absolute;
    background:rgba(255, 255, 255, 0.3);
    border-radius: 100%;
    -webkit-transform:scale(0);
    -moz-transform:scale(0);
    -o-transform:scale(0);
    transform:scale(0);
}
.animate {
    -webkit-animation:ripple 0.65s linear;
    -moz-animation:ripple 0.65s linear;
    -ms-animation:ripple 0.65s linear;
    -o-animation:ripple 0.65s linear;
    animation:ripple 0.65s linear;
}
@-webkit-keyframes ripple {
    100% {
        opacity: 0;
        -webkit-transform: scale(2.5);
    }
}
@-moz-keyframes ripple {
    100% {
        opacity: 0;
        -moz-transform: scale(2.5);
    }
}
@-o-keyframes ripple {
    100% {
        opacity: 0;
        -o-transform: scale(2.5);
    }
}
@keyframes ripple {
    100% {
        opacity: 0;
        transform: scale(2.5);
    }
}

JavaScript

var supportsTouch = 'ontouchstart' in window || navigator.msMaxTouchPoints,
    eType = supportsTouch ? 'touchend' : 'click';

$('button.btn').on(eType, function (e) {
    var $this = $(this),
        ink, d, x, y;
    
    //detect if ink is already prepended
    if (!$this.find('span.ink').length) {
        ink = $this.prepend("<span class='ink'></span>");
    }

    //stop animation
    ink = $this.find('span.ink').removeClass('animate');

    //set ink dimensions
    if (!ink.height() && !ink.width()) {
        d = Math.max($this.outerWidth(), $this.outerHeight());
        ink.css({
            height: d,
            width: d
        });
    }

    //calculate animation direction
    x = e.pageX - $this.offset().left - ink.width() / 2;
    y = e.pageY - $this.offset().top - ink.height() / 2;

    //set css and animate
    ink.css({
        top: y + 'px',
        left: x + 'px'
    }).addClass("animate");
});