Dark CSS

Create Button with Click Effect using Html and CSS

Facebook
Twitter
WhatsApp

Code preview

html Code

				
					<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
     
    <button class="button">
        <span class="shadow"></span>
        <span class="edge"></span>
        <span class="front"> Click Me!</span>
    </button>

</body>
</html>
				
			

css Code

				
					* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

html,
body {
    display: grid;
    height: 100%;
    place-items: center;
    background: #e8e8e8;
}

.button {
    position: relative;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    outline-offset: 4px;
    transition: filter 250ms;
}

.shadow {
    position: absolute;
    top: 5px;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background: hsl(0deg 0% 0% / 0.25);
    will-change: transform;
    transform: translateY(2px);
    transition: transform 600ms cubic-bezier(0.3, 0.7, 0.4, 1);
}

.edge {
    position: absolute;
    top: 3px;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background: linear-gradient(to left,
            hsl(246, 100%, 16%) 0%,
            hsl(246, 100%, 32%) 8%,
            hsl(246, 100%, 32%) 92%,
            hsl(244, 100%, 16%) 100%);
}

.front {
    display: block;
    position: relative;
    padding: 12px 42px;
    border-radius: 12px;
    font-size: 1.25rem;
    color: white;
    background: hsl(212, 100%, 47%);
    will-change: transform;
    transform: translateY(-4px);
    transition: transform 600ms cubic-bezier(0.3, 0.7, 0.4, 1);
}

.button:hover {
    filter: brightness(110%);
}

.button:hover .front {
    transform: translateY(-6px);
    transition: transform 250ms cubic-bezier(0.3, 0.7, 0.4, 1.5);
}

.button:hover .shadow {
    transform: translateY(4px);
    transition: transform 250ms cubic-bezier(0.3, 0.7, 0.4, 1.5);
}

.button:active .front {
    transform: translateY(-2px);
    transition: transform 34ms;
}

.button:active .shadow {
    transform: translateY(-6px);
    transition: transform 34ms;
}