پیشنمایش زنده
کد HTML
<div class="button-wrapper">
<button class="glossy-button">
<span>Button</span>
</button>
</div>
کد CSS
.button-wrapper {
position: relative;
width: 200px;
height: 100px;
border-radius: 25px;
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
transition: all 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
transform: translateZ(0);
will-change: transform, box-shadow;
backface-visibility: hidden;
}
.button-wrapper:hover {
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
cursor: pointer;
text-decoration: none;
border: none;
-webkit-tap-highlight-color: transparent;
transform: translateY(-3px) translateZ(0);
}
.button-wrapper:active {
box-shadow:
inset 0px 5px 12px 0px rgba(0, 0, 0, 0.18),
0 4px 12px rgba(0, 0, 0, 0.1);
transform: translateY(2px) scale(0.99) translateZ(0);
transition: all 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.glossy-button {
position: absolute;
top: 4px;
left: 4px;
display: flex;
justify-content: center;
align-items: center;
width: 192px;
height: 92px;
padding: 4px;
border-radius: 21px;
background: linear-gradient(to bottom, #e8e8e8, #a8a8a8);
box-shadow:
inset 0 1px 1px rgba(255, 255, 255, 0.9),
inset 0 -2px 2px rgba(0, 0, 0, 0.25);
cursor: pointer;
text-decoration: none;
border: none;
-webkit-tap-highlight-color: transparent;
transition: all 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
transform: translateZ(0);
will-change: transform, box-shadow;
backface-visibility: hidden;
}
.button-wrapper:hover .glossy-button {
transform: translateY(-3px) translateZ(0);
box-shadow:
inset 0 1px 1px rgba(255, 255, 255, 0.95),
inset 0 -2px 2px rgba(0, 0, 0, 0.2);
}
.button-wrapper:active .glossy-button {
transform: scale(0.99) translateZ(0);
transition: all 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
box-shadow:
inset 0 2px 4px rgba(0, 0, 0, 0.3),
inset 0 -1px 2px rgba(255, 255, 255, 0.8);
}
.glossy-button::before {
content: "";
position: absolute;
top: 4px;
left: 4px;
right: 4px;
bottom: 4px;
border-radius: 17px;
background-image: linear-gradient(
to bottom,
rgba(255, 255, 255, 0.7) 0%,
rgba(255, 255, 255, 0.15) 45%,
transparent 60%
),
radial-gradient(
ellipse 140% 80% at 120% -20%,
transparent 48%,
rgba(255, 255, 255, 0.2) 48.5%,
transparent 50%
),
radial-gradient(
ellipse 140% 80% at -20% 120%,
transparent 48%,
rgba(255, 255, 255, 0.2) 48.5%,
transparent 50%
),
linear-gradient(to top, rgba(0, 255, 255, 0.4) 0%, transparent 20%),
linear-gradient(135deg, #76d266 40%, #0c3258 85%);
box-shadow:
inset 0 4px 6px rgba(0, 0, 0, 0.4),
inset 0 -4px 8px rgba(255, 255, 255, 0.2);
transition: all 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
will-change: box-shadow;
backface-visibility: hidden;
}
.button-wrapper:hover .glossy-button::before {
box-shadow:
inset 0 3px 5px rgba(0, 0, 0, 0.35),
inset 0 -3px 6px rgba(255, 255, 255, 0.25);
}
.button-wrapper:active .glossy-button::before {
box-shadow:
inset 0 2px 8px rgba(255, 255, 255, 0.13),
inset 0 -6px 12px rgba(0, 0, 0, 0.18);
transition: all 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.glossy-button span {
position: relative;
z-index: 1;
font-family: "Roboto", sans-serif;
font-size: 30px;
font-weight: 600;
color: white;
letter-spacing: 2px;
text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
transition: all 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
transform: translateZ(0);
will-change: transform, text-shadow;
backface-visibility: hidden;
}
.button-wrapper:hover .glossy-button span {
transform: translateY(-2px) translateZ(0);
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
.button-wrapper:active .glossy-button span {
transform: translateY(2px) translateZ(0);
text-shadow: 0 0px 2px rgba(0, 0, 0, 0.6);
transition: all 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.glossy-button:focus-visible {
outline: 3px solid #5dadec;
outline-offset: 4px;
transition: outline 200ms ease;
}
.button-wrapper::after {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 25px;
background: linear-gradient(
135deg,
rgba(255, 255, 255, 0.1) 0%,
transparent 50%,
rgba(0, 0, 0, 0.05) 100%
);
pointer-events: none;
opacity: 0;
transition: opacity 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
will-change: opacity;
backface-visibility: hidden;
}
.button-wrapper:hover::after {
opacity: 1;
}
.button-wrapper:active::after {
opacity: 0;
transition: opacity 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.button-wrapper:active .reflection {
opacity: 0.18;
}
.button-wrapper .reflection {
position: absolute;
left: 20px;
right: 20px;
bottom: -18px;
height: 18px;
border-radius: 0 0 16px 16px;
background: linear-gradient(
to bottom,
rgba(255, 255, 255, 0.18) 0%,
rgba(255, 255, 255, 0.01) 100%
);
opacity: 0;
pointer-events: none;
transition: all 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
z-index: 0;
transform: translateZ(0);
will-change: transform, opacity;
backface-visibility: hidden;
}
.button-wrapper:hover .reflection {
opacity: 0.3;
transform: translateY(-3px) translateZ(0);
}
.button-wrapper::before {
content: "";
position: absolute;
left: 8px;
right: 8px;
bottom: 6px;
height: 10px;
border-radius: 0 0 16px 16px;
background: linear-gradient(
to top,
rgba(255, 255, 255, 0.18) 0%,
rgba(255, 255, 255, 0) 100%
);
z-index: 2;
pointer-events: none;
transition: all 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
opacity: 1;
transform: translateZ(0);
will-change: transform, opacity;
backface-visibility: hidden;
}
.button-wrapper:hover::before {
opacity: 1.2;
transform: translateY(-2px) translateZ(0);
}
.button-wrapper:active::before {
opacity: 0.3;
transform: translateY(2px) translateZ(0);
transition: all 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
@keyframes subtle-pulse {
0%,
100% {
transform: scale(1) translateZ(0);
}
50% {
transform: scale(1.01) translateZ(0);
}
}
.button-wrapper:hover .glossy-button::before {
animation: subtle-pulse 3s ease-in-out infinite;
}
.button-wrapper::before {
content: "";
position: absolute;
top: -2px;
left: -2px;
right: -2px;
bottom: -2px;
border-radius: 27px;
background: linear-gradient(
135deg,
rgba(118, 210, 102, 0.3),
rgba(12, 50, 88, 0.3)
);
opacity: 0;
transition: opacity 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
z-index: -1;
filter: blur(8px);
will-change: opacity;
backface-visibility: hidden;
}
.button-wrapper:hover::before {
opacity: 0.6;
}