A shimmer effect is a sleek and modern way to add a glowing animation to text elements on your website. This tutorial will guide you through creating a stunning shimmer effect using only HTML and CSS, making your headings and titles stand out.
What is a Shimmer Effect?
The shimmer effect creates a moving light reflection across text, giving it a polished and dynamic look. This effect is widely used in UI elements, loading screens, and modern web design to enhance visual appeal.
Why Use the Shimmer Effect?
โ
Enhances the aesthetic appeal of text โจ
โ
Creates an eye-catching, modern design ๐จ
โ
Uses only HTML and CSSโno JavaScript needed! ๐ ๏ธ
โ
Works across all devices and browsers ๐
โ
Lightweight and performance-friendly ๐
Step-by-Step Guide to Creating a Shimmer Effect
1๏ธโฃ Set Up the HTML Structure
Begin with a simple HTML file that includes a heading where the shimmer effect will be applied:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shimmer Effect</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1 class="shimmer-text">Shimmer Effect</h1>
</body>
</html>
2๏ธโฃ Styling the Shimmer Effect with CSS
Now, letโs add some CSS to create the shimmer animation:
body {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: Arial, sans-serif;
background-color: #1a1a1a;
color: white;
}
/* Shimmer Text Style */
.shimmer-text {
font-size: 3rem;
font-weight: bold;
position: relative;
color: #fff;
overflow: hidden;
white-space: nowrap;
letter-spacing: 2px;
}
/* Shimmer Animation */
.shimmer-text::before {
content: '';
position: absolute;
top: 0;
left: -100%;
height: 100%;
width: 100%;
background: linear-gradient(120deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0) 100%);
animation: shimmer-animation 2s infinite;
}
/* Shimmer Animation Keyframes */
@keyframes shimmer-animation {
0% {
left: -100%;
}
100% {
left: 100%;
}
}
3๏ธโฃ How It Works
- The
.shimmer-text
class styles the text and positions it relatively. - The
::before
pseudo-element creates an overlay with a gradient effect. - The
@keyframes
animation moves the gradient from left to right, creating a shimmering effect.
Customization Options
You can tweak the effect to suit your design:
- Change animation speed: Adjust the
2s
duration in@keyframes
to make it faster or slower. - Modify the gradient: Experiment with different opacity values for a softer or sharper effect.
- Apply to other elements: Use the
.shimmer-text
class on buttons, divs, or other elements for a unique look.
Where to Use the Shimmer Effect?
๐ก Animated headings for websites
๐ฎ Game UI elements
๐ Loading indicators
โจ Attention-grabbing call-to-action buttons
Watch the Video Tutorial
๐ฅ Learn visually with our step-by-step video guide! Watch it here:
Get the Source Code
๐ Access the complete source code on GitHub: Madras Academy GitHub
By following this guide, youโve successfully created a smooth shimmer effect using only HTML and CSS. Try experimenting with different styles to enhance your web design!
If you found this tutorial helpful, donโt forget to like, comment, and share! ๐๐ก