<input type="checkbox" id="like-toggle" class="like-checkbox">
<label for="like-toggle" class="like-heart">
<svg viewBox="0 0 24 24" fill="currentColor">
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/>
</svg>
</label>* { box-sizing: border-box; }
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: #fdf2f8;
}
.like-checkbox {
display: none;
}
.like-heart {
cursor: pointer;
width: 60px;
height: 60px;
display: flex;
justify-content: center;
align-items: center;
color: #cbd5e1;
transition: transform 0.2s;
position: relative;
}
.like-heart svg {
width: 40px;
height: 40px;
transition: fill 0.3s;
}
.like-heart:hover {
transform: scale(1.1);
}
/* Checked State */
.like-checkbox:checked + .like-heart {
color: #e11d48;
animation: bounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
/* Particle Explosion (using box-shadow trick) */
.like-checkbox:checked + .like-heart::after {
content: "";
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
z-index: -1;
box-shadow:
-25px -25px 0 -15px #e11d48,
25px -25px 0 -15px #e11d48,
-25px 25px 0 -15px #e11d48,
25px 25px 0 -15px #e11d48;
animation: particles 0.4s forwards;
}
@keyframes bounce {
0% { transform: scale(1); }
50% { transform: scale(1.3); }
100% { transform: scale(1); }
}
@keyframes particles {
0% { transform: scale(0.5); opacity: 1; }
100% { transform: scale(1.5); opacity: 0; }
}Nothing to show yetType HTML, CSS or JavaScript and your page appears here.
Click any element to find its code Esc
Check this code before you run it
It came from a shared link. It runs with fewer permissions, so it cannot open pop-ups, submit forms or start downloads.
0.00s / 0.00s
Nothing has animated yet. Hover, click or type in the preview and each CSS animation, transition or
element.animate() call shows up here as it plays.