Sparkling Transparent Backgrounds for Extra Shine
Discovering sparkles with clear backgrounds isn't just a children's fascination, but a creative designer's dream. This enchanting effect, achieved with clever use of CSS and HTML, can bring a touch of magic to any webpage. Let's dive into the world of transparent background sparkles and make your webpage shine!
In this guide, we'll explore two primary aspects: creating sparkles from scratch and making backgrounds transparent. Plus, we'll delve into some captivating use cases to inspire your designing journey.
Creating Sparkles from Scratch
Before making backgrounds transparent, let's first learn how to create sparkles using CSS. The secret lies in utilizing the ::before and ::after pseudo-elements, along with some fancy CSS properties like border, border-radius, and box-shadow.
Here's a simple example to kickstart your sparkle creation:
<span class="sparkle"></span>
And here's the CSS partner for this element:
.sparkle::before,
.sparkle::after {
content: '';
border-radius: 50%;
position: absolute;
background: #fff;
}
.sparkle::before {
width: 10px;
height: 10px;
top: -5px;
left: -5px;
animation: sparkle 1s linear infinite;
box-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #fff, 0 0 25px #fff, 0 0 30px #fff;
}
.sparkle::after {
width: 5px;
height: 5px;
top: 0px;
left: 0px;
animation: sparkle 1s linear infinite, pulsate 1s cubic-bezier(0.6, 0.2, 0, 1) infinite;
box-shadow: 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff, 0 0 5px #fff, 0 0 6px #fff, 0 0 7px #fff, 0 0 8px #fff, 0 0 9px #fff, 0 0 10px #fff, 0 0 12px #fff, 0 0 14px #fff, 0 0 16px #fff, 0 0 20px #fff, 0 0 24px #fff, 0 0 30px #fff;
}
@interface {{
animation: sparkle 1s linear infinite;
animation: pulsate 1s cubic-bezier(0.6, 0.2, 0, 1) infinite;
}}