Full Source Code — Animated Learn More Button
HTML
CSS
JavaScript
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Animated & Centered Button</title> </head> <body> <a href="#" class="stylish-learn-more-button"> Learn More Now </a> </body> </html>
/* ── PAGE LAYOUT ─────────────────────────────────────────── */
body {
height: 100vh;
margin: 0;
display: flex; /* Flexbox to center the button */
justify-content: center; /* Center horizontally */
align-items: center; /* Center vertically */
background-color: #f4f7f9; /* Light grey-blue background */
overflow: hidden; /* Prevent scrollbars from animation */
}
/* ── ENTRANCE ANIMATION ──────────────────────────────────── */
/* fadeInScale: invisible + small + shifted down → visible + normal */
@keyframes fadeInScale {
0% {
opacity: 0; /* Fully transparent */
transform: scale(0.8) translateY(20px); /* 80% size, 20px below resting */
}
100% {
opacity: 1; /* Fully visible */
transform: scale(1) translateY(0); /* Normal size, resting position */
}
}
/* ── BUTTON BASE STATE ───────────────────────────────────── */
.stylish-learn-more-button {
/* Plays fadeInScale once on load; 'forwards' keeps the final visible state */
animation: fadeInScale 0.8s ease-out forwards;
display: inline-block; /* Allows padding and width to apply */
padding: 12px 28px; /* Vertical 12px, horizontal 28px */
font-size: 18px;
font-weight: 600;
letter-spacing: 0.5px; /* Slight tracking improves readability */
text-decoration: none; /* Remove underline from tag */
color: #ffffff;
/* Diagonal green gradient background */
background-image: linear-gradient(45deg, #4CAF50, #8BC34A);
border: none;
border-radius: 50px; /* Pill shape — any value > height/2 works */
/* Resting shadow: slight Y offset, large blur, semi-transparent green */
box-shadow: 0 4px 15px rgba(0, 128, 0, 0.4);
cursor: pointer;
/* Smooths ALL property changes (gradient swap, shadow, transform) */
transition: all 0.3s ease;
}
/* ── HOVER STATE: LIFT + STRONGER GLOW ──────────────────── */
.stylish-learn-more-button:hover {
/* Reverse gradient direction — subtle color position swap */
background-image: linear-gradient(45deg, #8BC34A, #4CAF50);
/* Larger spread + higher opacity = more intense glow */
box-shadow: 0 8px 20px rgba(0, 128, 0, 0.6);
/* Lift button 2px upward — simulates object moving toward a light source */
transform: translateY(-2px);
}
/* ── ACTIVE STATE: PRESS DOWN ────────────────────────────── */
.stylish-learn-more-button:active {
/* Reduced shadow — button is pressed down, less distance to surface */
box-shadow: 0 2px 5px rgba(0, 128, 0, 0.4);
/* Return to resting position — simulates physical button depression */
transform: translateY(0);
}
// No JavaScript required
// Pure HTML + CSS animation
// ── HOW TO EXTEND WITHOUT JS ─────────────────────────────
// Shimmer effect (gradient sweep):
// 1. Add background-size: 200% 100% to base button
// 2. Add @keyframes shimmer { from { background-position: 0% } to { background-position: 200% } }
// 3. Add animation: shimmer 2s linear infinite to base button (combine with fadeInScale using a comma)
// Delayed entrance (stagger multiple buttons):
// .button-1 { animation-delay: 0.1s }
// .button-2 { animation-delay: 0.2s }
// .button-3 { animation-delay: 0.3s }
// Add arrow icon (no JS):
// <a href="#" class="stylish-learn-more-button">Learn More →</a>
// Or use a Font Awesome icon with <i class="fas fa-arrow-right"></i>