HTML
<button class="btn-3d" type="button" role="button">
<span class="btn-3d-shadow"></span>
<span class="btn-3d-edge"></span>
<span class="btn-3d-front text"> 3D Button </span>
</button>
CSS
.btn-3d {
position: relative;
border: none;
background: transparent;
padding: 0;
cursor: pointer;
outline-offset: 4px;
transition: filter 250ms;
user-select: none;
-webkit-user-select: none;
touch-action: manipulation;
}
.btn-3d-shadow {
position: absolute;
top: 0;
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(.3, .7, .4, 1);
}
.btn-3d-edge {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 12px;
background: linear-gradient(to left, hsl(340deg 100% 16%) 0%, hsl(340deg 100% 32%) 8%, hsl(340deg 100% 32%) 92%, hsl(340deg 100% 16%) 100%);
}
.btn-3d-front {
display: block;
position: relative;
padding: 12px 27px;
border-radius: 12px;
font-size: 1.1rem;
letter-spacing: 1px;
color: white;
background: hsl(345deg 100% 47%);
will-change: transform;
transform: translateY(-4px);
transition: transform 600ms cubic-bezier(.3, .7, .4, 1);
}
@media (min-width: 768px) {
.btn-3d-front {
font-size: 1.25rem;
padding: 12px 42px;
}
}
.btn-3d:hover {
filter: brightness(110%);
-webkit-filter: brightness(110%);
}
.btn-3d:hover .btn-3d-front {
transform: translateY(-6px);
transition: transform 250ms cubic-bezier(.3, .7, .4, 1.5);
}
.btn-3d:active .btn-3d-front {
transform: translateY(-2px);
transition: transform 34ms;
}
.btn-3d:hover .btn-3d-shadow {
transform: translateY(4px);
transition: transform 250ms cubic-bezier(.3, .7, .4, 1.5);
}
.btn-3d:active .btn-3d-shadow {
transform: translateY(1px);
transition: transform 34ms;
}
.btn-3d:focus:not(:focus-visible) {
outline: none;
}