2.0 KiB
2.0 KiB
title, tags
| title | tags |
|---|---|
| Pulse loader | animation |
Creates a pulse effect loader animation using animation-delay property.
<div class="ripple-loader">
<div></div>
<div></div>
</div>
.ripple-loader {
position: relative;
width: 64px;
height: 64px;
}
.ripple-loader div {
position: absolute;
border: 4px solid #76ff03;
border-radius: 50%;
animation: ripple-loader 1s ease-out infinite;
}
.ripple-loader div:nth-child(2) {
animation-delay: -0.5s;
}
@keyframes ripple-loader {
0% {
top: 32px;
left: 32px;
width: 0;
height: 0;
opacity: 1;
}
100% {
top: 0;
left: 0;
width: 64px;
height: 64px;
opacity: 0;
}
}
Explanation
Note: 1rem is usually 16px.
@keyframesdefines an animation at two points in the cycle, Start(0%), where thedivs neither have width nor height and are positioned at the center & End(100%), where thedivs have increasedheight&widthbutpositionis reset to 0.- The
divs seem to disappear as they expand. This is achieved usingopacityproperty, which transitions from 1 to 0 in the animation. .ripple-loaderis the parent container of the ripples and has a definite width and height. It usesposition: relativeto position child divs..ripple > div, targets the two childdivs of the parent to be styled. Thedivs are given a border of4px&border-radius: 50%to turn them from squares to circles.animationis a shorthand property for the various animation properties:animation-name,animation-duration,animation-direction,animation-iteration-countare used.nth-child(n)targets the element which is the nth child of its parent.animation-delayis used on the seconddiv, so that each element does not start the animation at the same time.