پیشنمایش زنده
کد HTML
<button class="btn" aria-label="Get started">
<span class="content">
<svg
class="icon"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
>
<path
d="M5 12h11"
stroke="currentColor"
stroke-width="1.6"
stroke-linecap="round"
stroke-linejoin="round"
></path>
<path
d="M13 6l6 6-6 6"
stroke="currentColor"
stroke-width="1.6"
stroke-linecap="round"
stroke-linejoin="round"
></path>
</svg>
<span>Get started</span>
</span>
<span class="badge">New</span>
</button>
کد CSS
.btn {
display: inline-grid;
grid-auto-flow: column;
align-items: center;
gap: 12px;
padding: 9px 20px; /* vertical | horizontal */
border-radius: 999px; /* pill */
border: 1px solid transparent;
cursor: pointer;
font:
600 15.5px/1 "Inter",
system-ui,
-apple-system,
"Segoe UI",
Roboto,
Arial;
color: #ffffff;
/* layered backgrounds: subtle frosted surface + animated conic border */
background:
linear-gradient(
180deg,
rgba(255, 255, 255, 0.03),
rgba(255, 255, 255, 0.01)
)
padding-box,
conic-gradient(from 120deg at 50% 50%, #7c3aed, #06b6d4, #8b5cf6) border-box;
background-size: 200% 200%;
animation: gradientShift 6s linear infinite;
box-shadow:
0 8px 30px rgba(2, 6, 23, 0.56),
0 3px 10px rgba(6, 182, 212, 0.04) inset;
position: relative;
overflow: hidden;
transform-origin: center;
transform-style: preserve-3d;
transition:
transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1),
box-shadow 0.28s,
filter 0.28s;
-webkit-tap-highlight-color: transparent;
}
/* inner frosted panel */
.btn::before {
content: "";
position: absolute;
inset: 0;
margin: 3px;
border-radius: 996px; /* slightly smaller than outer */
background: linear-gradient(
180deg,
rgba(255, 255, 255, 0.04),
rgba(255, 255, 255, 0.02)
);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
pointer-events: none;
backdrop-filter: blur(8px) saturate(120%);
mix-blend-mode: overlay;
}
/* moving sheen */
.btn::after {
content: "";
position: absolute;
left: -45%;
top: -30%;
width: 65%;
height: 160%;
background: linear-gradient(
90deg,
rgba(255, 255, 255, 0.3),
rgba(255, 255, 255, 0.06),
rgba(255, 255, 255, 0)
);
transform: rotate(-20deg) translateX(0);
transition:
transform 0.7s cubic-bezier(0.2, 0.9, 0.3, 1),
opacity 0.4s;
opacity: 0.95;
pointer-events: none;
filter: blur(6px);
}
/* content alignment */
.btn .content {
display: inline-flex;
align-items: center;
gap: 10px;
z-index: 1;
}
.btn .icon {
width: 18px;
height: 18px;
display: inline-block;
flex: 0 0 18px;
transition: transform 0.36s cubic-bezier(0.2, 0.9, 0.3, 1);
}
/* hover interactions: depth + 3D tilt */
.btn:hover {
transform: perspective(800px) translateY(-12px) rotateX(6deg) scale(1.02);
box-shadow:
0 36px 80px rgba(2, 6, 23, 0.64),
0 10px 34px rgba(6, 182, 212, 0.06) inset;
}
.btn:hover .icon {
transform: translateX(10px) rotate(8deg);
}
.btn:hover::after {
transform: rotate(-20deg) translateX(240%);
opacity: 1;
}
.btn:active {
transform: perspective(800px) translateY(-3px) rotateX(2deg) scale(0.995);
}
/* elegant focus ring */
.btn:focus {
outline: none;
box-shadow:
0 0 0 6px rgba(124, 58, 237, 0.08),
0 18px 40px rgba(2, 6, 23, 0.5);
}
/* subtle badge */
.btn .badge {
font-size: 11px;
padding: 4px 8px;
border-radius: 999px;
background: rgba(255, 255, 255, 0.06);
color: rgba(255, 255, 255, 0.95);
box-shadow: 0 2px 6px rgba(2, 6, 23, 0.35);
transform: translateZ(30px);
z-index: 1;
}
/* disabled state */
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none;
box-shadow: none;
}
/* reduced motion */
@media (prefers-reduced-motion: reduce) {
.btn {
animation: none;
transition: none;
}
.btn:hover {
transform: none;
}
.btn::after {
transition: none;
}
.btn .icon {
transition: none;
}
}
@keyframes gradientShift {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
@media (max-width: 420px) {
.btn {
gap: 8px;
padding: 8px 14px;
font-size: 15px;
}
.btn .icon {
width: 16px;
height: 16px;
}
}