پیشنمایش زنده
کد HTML
<button class="custom-button">
<span class="button-content">
<span class="button-text">Get Started</span>
<span class="button-icon">→</span>
</span>
<span class="button-background"></span>
</button>
کد CSS
/* Modern, clean button styling */
.custom-button {
position: relative;
padding: 14px 32px;
border: none;
border-radius: 12px;
cursor: pointer;
overflow: hidden;
font-family: "Inter", sans-serif;
isolation: isolate;
}
.button-content {
position: relative;
z-index: 1;
display: flex;
align-items: center;
gap: 8px;
font-size: 16px;
font-weight: 600;
color: #fff;
transition: transform 0.2s ease;
}
.button-background {
position: absolute;
inset: 0;
background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #6366f1 100%);
transition: all 0.3s ease;
}
.button-icon {
display: inline-flex;
transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
/* Hover effects */
.custom-button:hover .button-content {
transform: translateY(-1px);
}
.custom-button:hover .button-icon {
transform: translateX(4px);
}
.custom-button:hover .button-background {
transform: scale(1.05);
filter: brightness(1.1);
}
/* Active effects */
.custom-button:active .button-content {
transform: translateY(1px);
}
.custom-button:active .button-background {
transform: scale(0.98);
filter: brightness(0.95);
}
/* Focus styles */
.custom-button:focus-visible {
outline: 2px solid #4f46e5;
outline-offset: 2px;
}
/* Add subtle shadow */
.custom-button {
box-shadow:
0 2px 4px rgba(79, 70, 229, 0.1),
0 4px 8px rgba(79, 70, 229, 0.1),
0 -1px 2px rgba(79, 70, 229, 0.05);
transition: all 0.3s ease;
}
.custom-button:hover {
box-shadow:
0 4px 8px rgba(79, 70, 229, 0.2),
0 8px 16px rgba(79, 70, 229, 0.2),
0 -2px 4px rgba(79, 70, 229, 0.1);
}
/* Optional: Add a subtle shine effect */
@keyframes shine {
from {
transform: translateX(-100%) rotate(45deg);
}
to {
transform: translateX(100%) rotate(45deg);
}
}
.custom-button::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 50%;
height: 100%;
background: linear-gradient(
to right,
transparent,
rgba(255, 255, 255, 0.1),
transparent
);
transform: translateX(-100%) rotate(45deg);
z-index: 1;
}
.custom-button:hover::after {
animation: shine 1s ease;
}